For AI agents: markdown of this page — /docs-content-en/partner-connect/device-authorize.md documentation index — /llms.txt
Request a device sign-in code
POST /v1/connect/device/authorize
Issues a confirmation code for signing in from a device without a browser: a TV, a set-top box, a terminal utility — anywhere typing a login and password is awkward. The user confirms the sign-in on a phone or computer, and the device receives access. The flow is defined by RFC 8628.
The application needs device sign-in enabled: a platform administrator turns it on, and only for verified applications. A self-registered client gets 400 unauthorized_client — this protects users from confirmation codes displayed by unverified applications.
Request fields (body)
The request accepts application/json and application/x-www-form-urlencoded.
| Field | Type | Required | Description |
|---|---|---|---|
Fieldclient_id |
Typestring | Requiredyes | DescriptionIdentifier of the application for which a platform administrator has enabled device sign-in |
Fieldscope |
Typestring | Requiredno | DescriptionRequested permissions, separated by spaces or commas. If omitted, the permissions registered for the client apply |
Fieldcode_challenge |
Typestring | Requiredconditional | DescriptionSHA-256 hash of code_verifier in base64url without =. Required if PKCE is enabled in the client settings. The platform stores the submitted hash and checks it against code_verifier during polling |
Fieldcode_challenge_method |
Typestring | Requiredconditional | DescriptionS256, required together with code_challenge |
Fielddevice_id |
Typestring | Requiredno | DescriptionPersistent identifier of the application installation: up to 128 characters, Latin letters, digits and the characters ., :, -, _. The platform adds it to verification_uri_complete as the device_id parameter to link the steps of one sign-in, even if the link is opened in another browser. A value of any other form is dropped without an error: the response stays 200, and the link is returned without the parameter. Does not affect issuing a key to a third-party application |
Fieldlogin_source |
Typestring | Requiredno | DescriptionYour sign-in button label for statistics: a lowercase Latin letter followed by lowercase Latin letters, digits and _, up to 64 characters in total. Leading and trailing spaces are trimmed. An invalid label does not interrupt the sign-in and does not affect permissions or key issuance |
Fieldlast_connect_clear |
Typestring | Requiredno | DescriptionOptional window-clear receipt: a JSON string of up to 1024 UTF-8 bytes. Accepted and recorded only for keys of the official Cowork client (client_id=cowork-desktop); ignored for other clients. Invalid known values or an oversized receipt cause the entire receipt to be discarded without a connection error. Unknown fields are ignored and never recorded. Omitting the parameter preserves the existing connection flow |
Examples
The endpoint authenticates with the application identifier client_id in the request body. The X-Api-Key and Authorization headers are not needed.
Keep code_verifier until the exchange at POST /v1/connect/token. The curl example uses the RFC 7636 pair with code_verifier equal to dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk. Generate a new random pair for each sign-in, as in the JavaScript example.
curl — OAuth application
curl -X POST https://vibecode.bitrix24.com/v1/connect/device/authorize \
-H "Content-Type: application/json" \
-d '{"client_id":"YOUR_CLIENT_ID","scope":"crm","code_challenge":"E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM","code_challenge_method":"S256"}'
JavaScript — OAuth application
const base64url = bytes => btoa(String.fromCharCode(...bytes))
.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '')
const code_verifier = base64url(crypto.getRandomValues(new Uint8Array(32)))
const challenge = base64url(new Uint8Array(
await crypto.subtle.digest('SHA-256', new TextEncoder().encode(code_verifier)),
))
const res = await fetch('https://vibecode.bitrix24.com/v1/connect/device/authorize', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
client_id: 'YOUR_CLIENT_ID',
scope: 'crm',
code_challenge: challenge,
code_challenge_method: 'S256',
}),
})
const data = await res.json()
// data.user_code and data.verification_uri — show to the user
// data.device_code — keep on the device, do not display
Response fields
| Field | Type | Description |
|---|---|---|
Fielddevice_code |
Typestring | DescriptionDevice secret. Not displayed; sent when polling POST /v1/connect/token |
Fielduser_code |
Typestring | DescriptionCode shown to the user together with the URL |
Fieldverification_uri |
Typestring | DescriptionURL where the user enters the code |
Fieldverification_uri_complete |
Typestring | DescriptionThe same URL with user_code already filled in |
Fieldexpires_in |
Typeinteger | DescriptionNumber of seconds the user has to confirm |
Fieldinterval |
Typeinteger | DescriptionPolling interval for POST /v1/connect/token, in seconds |
Response example
{
"device_code": "MYQnuWB3H0tR...",
"user_code": "54BV-XT8F",
"verification_uri": "https://vibecode.bitrix24.com/connect/device",
"verification_uri_complete": "https://vibecode.bitrix24.com/connect/device?user_code=54BV-XT8F",
"expires_in": 899,
"interval": 5
}
Error response example
400 — device sign-in is not enabled for this client:
{
"error": "unauthorized_client",
"error_description": "Client is not enabled for the device flow"
}
Errors
Rejections come in the RFC 6749 form — { error, error_description }:
| HTTP | error |
Condition |
|---|---|---|
| HTTP400 | errorinvalid_request |
Conditionclient_id is missing. error_description — Missing client_id |
| HTTP401 | errorinvalid_client |
Conditionclient_id is unknown or the client is disabled |
| HTTP400 | errorunauthorized_client |
ConditionDevice sign-in is not enabled for this client. error_description — Client is not enabled for the device flow |
| HTTP400 | errorunauthorized_client |
ConditionThe client is in COMPANY mode. code and error_description — CONNECT_COMPANY_DEVICE_FLOW_FORBIDDEN |
| HTTP400 | errorinvalid_request |
ConditionThe client requires PKCE, and code_challenge is missing, the method is not S256, or the hash is invalid |
| HTTP400 | errorinvalid_scope |
ConditionAn unknown permission or a permission outside the client's registered set is requested |
The endpoint is rate-limited — 30 requests per minute per caller IP address; client_id is not part of the key. On top of that, the platform entry limiter applies, shared across all of /v1/. Exceeding either returns 429 in the common API envelope with a Retry-After header. The presence of X-RateLimit-Limit shows which one fired.
Full reference of common API errors — Errors.
Known specifics
The user opens the URL and confirms. On the confirmation screen they see the application card, the requested permissions, a Bitrix24 account selector and a phishing warning: confirm only a sign-in you started yourself.
The device polls /v1/connect/token.
curl -X POST https://vibecode.bitrix24.com/v1/connect/token \
-H "Content-Type: application/json" \
-d '{
"grant_type": "urn:ietf:params:oauth:grant-type:device_code",
"client_id": "YOUR_CLIENT_ID",
"device_code": "DEVICE_CODE",
"code_verifier": "CODE_VERIFIER"
}'
Until the user confirms, the request returns 400 with one of these states:
error |
What to do |
|---|---|
errorauthorization_pending |
What to doWait and keep polling every interval seconds |
errorslow_down |
What to doPolling is more frequent than allowed. Increase the interval by 5 seconds and continue |
erroraccess_denied |
What to doThe user declined. Stop polling |
erroraccess_denied with error_description=admin_approval_requested |
What to doThe user asked the Bitrix24 account administrator to allow AI for the application. Returned when administrator approval of AI is enabled on the platform. Stop polling, and after the administrator decides, request a new code via POST /v1/connect/device/authorize |
errorexpired_token |
What to doThe code has expired. Request a new one via POST /v1/connect/device/authorize |
errorinvalid_grant |
What to doThe user confirmed the sign-in, but code_verifier is missing or does not match code_challenge from the code request. Repeat the poll with the correct code_verifier |
Polling can also receive 429 — a rate limiter rejection, not an authorization state, and it comes in two forms because this route has two limiters. A rejection from the platform entry limiter comes in the RFC 6749 form (error equals slow_down) and without X-RateLimit-* headers. A rejection from the endpoint's own limiter comes in the common API envelope — { "success": false, "error": { "code": "RATE_LIMITED", "message": "..." } } — and carries X-RateLimit-* headers. A single branch on error === "slow_down" is therefore not enough: it misses half of the rejections.
Handle both the same way: wait at least the Retry-After value and continue polling without resetting your growing pause. To tell them apart if needed, check for X-RateLimit-Limit.
After confirmation the same request returns 200 with the key and two permission sets:
{ "api_key": "vibe_api_...", "scopes": ["crm"], "granted_scopes": ["crm"] }
Note: this object is narrower than in the main flow — without the portal and user blocks.
The key is returned once. A repeated poll with the same device_code returns expired_token, so save the key immediately.
What the device must do:
- Show a countdown. The code is valid for 15 minutes. When it expires, show a new one, not a dead screen.
- Respect
intervaland react toslow_down. Polling more often than allowed does not speed up issuance; it leads to rejections. - Read
Retry-Afterand increase its own pause. The header value is the minimum pause, not a guarantee that the next request is accepted: all running copies of the application compete for the per-IP limit. Wait at leastRetry-Afterand increase your pause with each rejection. - Do not display
device_code. Onlyuser_codegoes on screen.