Authenticate your backend
Your backend authenticates with an API credential that acts for your Account. Dockt supports two types: API keys and machine-to-machine (M2M) credentials. Both send a bearer token in the Authorization header.
Choose a credential type
Section titled “Choose a credential type”Start with an api_key: use the key itself as your bearer token. You can set an expiry date when you create it.
Use an m2m credential when your service can exchange a client ID and secret for short-lived access tokens. Refresh the token before its expires_in period ends.
Create your first credential
Section titled “Create your first credential”Create your first credential in the Dockt console under API credentials. Then follow Use an API key to set the environment variables and verify it.
Create additional credentials
Section titled “Create additional credentials”The following command uses curl and jq. To create additional credentials through the API, use an existing credential with api-credentials:manage. Set DOCKT_API_BASE_URL and DOCKT_API_TOKEN first, then call POST /v1/api-credentials:
curl --fail-with-body --silent --show-error \ -X POST "$DOCKT_API_BASE_URL/v1/api-credentials" \ -H "Authorization: Bearer $DOCKT_API_TOKEN" \ -H 'Content-Type: application/json' \ --data '{ "display_name": "Contractor portal backend", "credential_type": "api_key", "allowed_scopes": ["account:read", "account:write"] }' | jq '.data | {id, credential_type, allowed_scopes, api_key, client_id, client_secret, token_url}'The response contains the secret once: api_key for an API key, or client_id, client_secret and token_url for an M2M credential. Store it in your secret manager right away. Later reads return credential details and an API key hint, without the secret.
Creating a credential is not idempotent, because a replay would return the secret again. If a create request fails without a response, list your credentials with GET /v1/api-credentials and delete any you don’t use.
Use an API key
Section titled “Use an API key”Export the key for the examples:
export DOCKT_API_BASE_URL='https://api.dockt.com'export DOCKT_API_TOKEN='REPLACE_WITH_API_KEY'Send it as a bearer token:
curl --fail-with-body \ -H "Authorization: Bearer $DOCKT_API_TOKEN" \ "$DOCKT_API_BASE_URL/v1/auth/me"Use an M2M access token
Section titled “Use an M2M access token”To create an M2M credential, send "credential_type": "m2m" in the create request. Store the one-time client_secret with the returned client_id and token_url:
export DOCKT_API_BASE_URL='https://api.dockt.com'export DOCKT_CLIENT_ID='REPLACE_WITH_CLIENT_ID'export DOCKT_CLIENT_SECRET='REPLACE_WITH_CLIENT_SECRET'export DOCKT_TOKEN_URL='REPLACE_WITH_TOKEN_URL'Exchange the client credentials for an access token:
token_response="$( curl --fail-with-body --silent --show-error \ -X POST "$DOCKT_TOKEN_URL" \ -H 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode "client_id=$DOCKT_CLIENT_ID" \ --data-urlencode "client_secret=$DOCKT_CLIENT_SECRET" \ --data-urlencode 'grant_type=client_credentials')"
export DOCKT_API_TOKEN="$(printf '%s' "$token_response" | jq -r '.access_token')"The token response includes access_token, token_type and expires_in. Cache the token on your server and repeat the exchange before it expires.
Grant only the permissions you need
Section titled “Grant only the permissions you need”| Permission | Grant it when your backend |
|---|---|
account:read |
Reads Persons, Companies, Workplaces, Policies, work, Documents, Decisions, Outcomes, usage or the catalogues. |
account:write |
Creates or changes any of them, uploads documents, records Outcomes, or manages webhook endpoints and Connections. |
api-credentials:read |
Lists API credentials. |
api-credentials:manage |
Creates, updates or deletes API credentials. |
A backend that announces workers and reads Decisions needs account:read and account:write. A reporting job needs only account:read. You can grant only the permissions you hold yourself.
Authentication and permissions reference
Verify the credential
Section titled “Verify the credential”Call GET /v1/auth/me after loading your token:
curl --fail-with-body --silent --show-error \ -H "Authorization: Bearer $DOCKT_API_TOKEN" \ "$DOCKT_API_BASE_URL/v1/auth/me" | jq '.data | { auth_type, api_credential_type, principal_scope_type, permissions, account: .active_scope.scope_id }'Check that auth_type is api_credential, that account is the Account you expect, and that permissions covers every operation your integration uses.
Protect and rotate credentials
Section titled “Protect and rotate credentials”- Keep credentials in a server-side secret manager.
- Use a separate credential for each application and environment.
- To rotate, create a new credential, deploy it, then delete the old one with
DELETE /v1/api-credentials/{credentialId}. A deleted credential stops working at once. - Disable a credential temporarily with
PATCH /v1/api-credentials/{credentialId}and"enabled": false. - Never log bearer tokens, API keys, client secrets or document files.
- Treat
401as an authentication failure and403as a missing permission.