Account authorization
Create provider authorization session
Creates a short-lived hosted authorization session for a WhatsApp account using auth_mode=qrcode. Open authorize_url in the user’s browser and treat the complete URL as a sensitive credential that must not be logged or shared.
https://api.unifyport.ai/v1/accounts/{account_id}/auth-sessionsSupported channels
Before you call
Use a server-side X-Api-Key for the workspace that owns the resource. Replace every placeholder before running a sample.
Prepare your parameters
- account_id
- Use data.id from account creation or an account query. Account identifiers belong to the workspace selected by X-Api-Key. Get account
Request parameters
Headers
X-Api-KeyWorkspace API key. The workspace is resolved from this header.
Path parameters
account_idIdentifier used in the authentication route.
Request body
This endpoint does not require a JSON request body.
Understand the result
Read status/auth_status and any auth_payload for the requested authorization action. Follow the channel guide when user input is needed; authorized means authorization is complete. Check runtime_status before sending messages.
Response 201 Created
{
"request_id": "<REQUEST_ID>",
"data": {
"account_id": "acc_example",
"provider": "whatsapp",
"auth_mode": "qrcode",
"status": "passkey_required",
"auth_payload": {
"type": "passkey",
"public_key": {
"challenge": "<BASE64URL_CHALLENGE>"
}
},
"authorize_url": "https://auth.example.com/authorize/whatsapp/<SESSION_TOKEN>",
"expires_at": "2026-08-12T08:10:00Z",
"switchable": false,
"available_auth_modes": [
"qrcode"
]
}
}
Response body
account_idProvider account this response refers to.
providerChannel identifier. Use the API value unchanged in later calls; see the enum below for the values returned by this endpoint.
enum: whatsapp
auth_modeAuthentication mode for this authorization session; currently qrcode.
statusCurrent authorization flow status, for example pending_auth, awaiting_qr_scan, awaiting_code, pending, passkey_required, passkey_pending, passkey_confirmation, passkey_confirmation_sent, authorized, or failed.
auth_payloadStandard payload needed for the current step. QR uses qr_code; code verification uses type=code; Passkey may return type=passkey and public_key, or type=passkey_confirmation with confirmation prompts. Mutually exclusive step payloads do not appear together. TikTok session may return QR or verification-code prompts when interaction is needed; HTTP 200 does not mean authorization succeeded.
authorize_urlShort-lived hosted authorization URL containing an opaque credential. Never log or share the complete URL.
format: uri
expires_atRFC3339 timestamp after which the current auth_payload is no longer valid.
format: date-time
switchableWhether the hosted authorization session allows the user to switch authentication modes.
available_auth_modes[]Authentication modes available within the hosted authorization session.
Responses
201201 Created
Request succeeded. See the example response body.
400Bad Request
The request body, path, or parameters are invalid.
401Unauthorized
The X-Api-Key header is missing or invalid.
403Forbidden
The request is authenticated but is not allowed.
404Not Found
The requested resource was not found. Check error.code and the current operation.
409Conflict
The requested operation conflicts with an existing provider account or resource.
500Internal Server Error
The service encountered an unexpected error.
503Service Unavailable
A required backend service is temporarily unavailable.
If the request fails
Inspect HTTP status and error.code/numeric_code, and keep request_id for diagnosis. Correct invalid parameters, complete required authorization or check runtime state as appropriate. Confirm the outcome before retrying a send or another write. Error reference
Read HTTP status, error.code and error.numeric_code together in the context of the current operation. Numeric codes are strings. Keep request_id for diagnosis; it is not an idempotency key or a task identifier.
- invalid_request · 10000 · 400
Check the JSON body and required fields.
When it occurs: Applies when a non-empty request body is sent with a Content-Type other than application/json.
What to do: Correct the parameters for this operation and channel before requesting again. Repeating an unchanged invalid request will not resolve the error.
Illustrative JSON; message varies with the actual cause · 400 · 10000
{ "request_id": "req_example", "error": { "code": "invalid_request", "numeric_code": "10000", "message": "Content-Type must be application/json" } }- invalid_target_workspace · 11003 · 400
The workspace override target is empty or malformed. Remove the override header and use the API key belonging to the intended workspace.
When it occurs: Applies when the request includes the X-Workspace-Id workspace override header.
What to do: Correct the parameters for this operation and channel before requesting again. Repeating an unchanged invalid request will not resolve the error.
Illustrative JSON; message varies with the actual cause · 400 · 11003
{ "request_id": "req_example", "error": { "code": "invalid_target_workspace", "numeric_code": "11003", "message": "Invalid target workspace" } }- unsupported_provider_auth_mode · 20018 · 400
Choose an auth_mode supported by this channel.
What to do: Use a channel and action listed as supported. Repeating the same request does not add capabilities or grant beta access.
Illustrative JSON; message varies with the actual cause · 400 · 20018
{ "request_id": "req_example", "error": { "code": "unsupported_provider_auth_mode", "numeric_code": "20018", "message": "Auth mode not supported by this provider" } }- invalid_api_key · 11001 · 401
Check whether the API key is correct and enabled.
What to do: Keep request_id and the structured codes, and investigate the current operation before taking another action.
Illustrative JSON; message varies with the actual cause · 401 · 11001
{ "request_id": "req_example", "error": { "code": "invalid_api_key", "numeric_code": "11001", "message": "Invalid API key" } }- missing_api_key · 11000 · 401
Add the X-Api-Key header.
What to do: Keep request_id and the structured codes, and investigate the current operation before taking another action.
Example · 401 · 11000
{ "request_id": "req_xxx", "error": { "code": "missing_api_key", "numeric_code": "11000", "message": "Missing X-Api-Key header" } }- workspace_override_forbidden · 11002 · 403
The request attempts a workspace override that this API key is not allowed to use. Remove the override header and use the API key belonging to the intended workspace.
When it occurs: Applies when the request includes the X-Workspace-Id workspace override header.
What to do: Keep request_id and the structured codes, and investigate the current operation before taking another action.
Illustrative JSON; message varies with the actual cause · 403 · 11002
{ "request_id": "req_example", "error": { "code": "workspace_override_forbidden", "numeric_code": "11002", "message": "Workspace override is not allowed" } }- target_workspace_not_found · 11004 · 404
The overridden workspace was not found or is unavailable. Verify workspace ownership, remove the override header and use the intended workspace’s API key; repeated requests do not grant access.
When it occurs: Applies when the request includes the X-Workspace-Id workspace override header.
What to do: Check the target identifier, resource ownership and current workspace. Do not treat a confirmed missing or inaccessible target as a temporary service failure to retry automatically.
Illustrative JSON; message varies with the actual cause · 404 · 11004
{ "request_id": "req_example", "error": { "code": "target_workspace_not_found", "numeric_code": "11004", "message": "Target workspace not found" } }- egress_configuration_pending · 20032 · 409
The platform default network configuration cannot currently be confirmed or loaded. This does not mean the account is logged out.
When it occurs: The operation uses platform-managed network capacity or a fixed default network configuration.
What to do: Keep request_id and check the account or creation result before another write. Wait for capacity or configuration recovery, or contact support. Do not repeatedly create accounts, change networks, or restart accounts automatically.
Illustrative JSON; message varies with the actual cause · 409 · 20032
{ "request_id": "req_example", "error": { "code": "egress_configuration_pending", "numeric_code": "20032", "message": "Account network configuration is pending verification" } }- provider_not_ready · 30009 · 409
The connection is not ready. Check authorization and runtime_status before retrying.
What to do: Query authorization and runtime status, then choose refresh, start or reconnect only when appropriate for the intended state and channel. A connection problem alone does not prove logout. Confirm running before dependent business operations.
Illustrative JSON; message varies with the actual cause · 409 · 30009
{ "request_id": "req_example", "error": { "code": "provider_not_ready", "numeric_code": "30009", "message": "Provider client is not ready" } }- run_auth_action_failed · 20010 · 500
Run an authorization action: the authorization action failed; check the existing flow rather than assuming authorization must restart.
What to do: Query the current authorization flow and check whether user action is required. Do not start another authorization attempt merely because this request failed; do not resubmit an expired or finished session.
Illustrative JSON; message varies with the actual cause · 500 · 20010
{ "request_id": "req_example", "error": { "code": "run_auth_action_failed", "numeric_code": "20010", "message": "Failed to run auth action" } }- run_auth_action_failed · 20020 · 500
Check account_id and use an X-Api-Key for the workspace that owns the account. An account not found in this workspace cannot be accessed with this key.
When it occurs: Applies when the account is not found; the existing HTTP status and operation code are preserved, while numeric_code identifies the missing account.
What to do: Check the target identifier, resource ownership and current workspace. Do not treat a confirmed missing or inaccessible target as a temporary service failure to retry automatically.
Illustrative JSON; message varies with the actual cause · 500 · 20020
{ "request_id": "req_example", "error": { "code": "run_auth_action_failed", "numeric_code": "20020", "message": "Account not found" } }- internal_auth_not_configured · 11006 · 503
The authorization-session service is unavailable or not configured for this request. Contact the service operator to check the authorization-session service.
What to do: Keep request_id and the structured codes, and investigate the current operation before taking another action.
Illustrative JSON; message varies with the actual cause · 503 · 11006
{ "request_id": "req_example", "error": { "code": "internal_auth_not_configured", "numeric_code": "11006", "message": "Internal endpoint authentication is not configured" } }