Connect the API for leads
Create a studio API key, send a test lead from your server and check that repeating the request returns the same result without a duplicate.
In this guide
- Who it is for
- The studio owner or admin and the integration developer.
- What to prepare
- Active access to the studio, permission to manage API keys and a server with Node.js 24 for the test example.
From a key to a lead in the CRM
- Open the CRM of your studio and go to Settings → Communications → API and integrations («Налаштування → Комунікації → API та інтеграції»).
- Click Create API key («Створити API-ключ») and set a name and expiry date. For the example, select both permissions: Read leads («Читати заявки», leads.read) and Create leads («Створювати заявки», leads.create).
- Store the secret, which is shown only once, in the CLUBBASE_API_KEY environment variable on the integration server. Do not put it in public page code, a browser request or a URL.
- Download the Server example (Node.js) from the link at the bottom and follow the Test run section.
- Open Leads («Заявки») in the same CRM and find the lead «Приклад API» by the test email with your UUID. On success the example returns the ID of this lead, replay: same_result and read: PASS.
Available methods
A key works only with the studio that issued it. Pass it in the Authorization: Bearer header. The fields, responses, pagination and quotas are described in the API documentation; the OpenAPI JSON is available at a separate link.
| Method | Permission | Result |
|---|---|---|
| POST /v1/integrations/leads | leads.create | Creates a lead; needs an Idempotency-Key with the UUID of this operation. |
| GET /v1/integrations/leads/{id} | leads.read | The current status of a lead by its ID. |
| GET /v1/integrations/leads | leads.read | The list of leads in pages, using limit and cursor. |
Test run
The example writes one test lead «Приклад API» with an email in the example.test domain to the studio of your key. It sends two identical create requests and reads the result by ID. This checks your connection; running it creates a record in the CRM.
- Save the downloaded file as integration-leads.mjs on a server with Node.js 24.
- In the server environment, set CLUBBASE_API_URL=https://api.clubbase.fit without /v1 at the end, and CLUBBASE_API_KEY with the stored secret.
- Generate a UUID, save it and set it as CLUBBASE_REQUEST_ID. To repeat this test lead, keep the same UUID.
- Run node integration-leads.mjs. If a response is lost, run it again with the same CLUBBASE_REQUEST_ID. Without this variable, every run generates a new UUID and creates a new test lead.
Replacing a key and repeating a request
Replace secret («Замінити секрет») turns off the old secret at once but keeps the integration ID and the retry history. Update CLUBBASE_API_KEY on the server; to repeat an earlier operation, keep its UUID and the same data. A new lead needs a new UUID.
Revoke («Відкликати») turns the key off for good. An expired key does not work either. If the person who issued the key has lost the required permissions, the owner or an admin has to replace the secret. Suspending access to the studio stops API requests.
The current API covers creating and reading leads.
Result
The test lead is in the right CRM; repeating the same operation returns the original result without a duplicate, and GET by ID shows the current status.
If it did not work
For 401, check the secret, its expiry and revocation; for 403, the key’s permissions and its current issuer; for 402, the studio’s access status. For 409, check the UUID, that the retried data is unchanged and whether this contact already has an open lead. After 429, wait for the Retry-After period; for 503, retry later with the same UUID. The full list of codes and quotas is in the API documentation. A password or a browser session does not replace an API key.