OAuth
Let an app or an MCP client call the API for a member who approved it: create an app, authorize, tokens, refresh and revoke.
Overview
OAuth lets an app call the Attia API for a member who approved it, without a personal API key. The member signs in to Attia, picks a workspace and approves the app. The app gets an access token for that workspace.
The app reads only what the member who approved it can see. Attia checks the member, the scopes they approved and their role on every call, so when the member leaves the workspace, Attia refuses the app's next call.
OAuth for the API is available on Business and Enterprise, as API keys are. Every example below uses https://attia.app and placeholders such as <client_id>. Replace each placeholder, brackets included, with your own value.
Create an app
A workspace admin registers the app under Settings → API, in the OAuth applications section. Add each redirect URI the app uses. Attia compares a redirect URI as an exact string, so https://example.com/oauth/callback/ with a trailing slash is a different URI. After Create, copy the client ID and the client secret. Attia shows the secret only once. OAuth applications describes each field.
A member of the app's own workspace can approve the app there. Turn on Public to let members of other workspaces approve it in theirs.
MCP clients that register themselves
An MCP client connects to https://mcp.attia.app/mcp without an app an admin created. It reads the authorization server from the MCP server's protected resource metadata, at https://mcp.attia.app/.well-known/oauth-protected-resource/mcp, and registers itself there in one of two ways:
- Client ID metadata document: the client ID is an
httpsURL with a path, where the client publishes its metadata. The consent screen names the client by that URL's host. - Dynamic client registration: the client registers its name and redirect URIs and gets a client ID. The consent screen shows the name it registered.
A member's first Approve or Request approval adds the client to Attia. Opening the consent screen adds nothing. The client is public, so a member of any workspace can approve it, and it then appears under Settings → Authorized applications like any other app. It has no client secret, no webhook and no page under Settings → API.
Such a client gets tokens for the MCP server only, https://mcp.attia.app/mcp or https://mcp.attia.app/mcp/readonly, with the scopes it asks for out of the ones that address offers: read, write, candidates:read and candidates:write, or read and candidates:read on the read-only address. Each token also carries user:org:read, so it names the workspace the member picked, and offline_access, so the client gets a refresh token.
The client exchanges the code, refreshes and revokes at the endpoints the authorization server's metadata names, not at Attia's /oauth/token and /oauth/revoke, and it has no client secret. Each refresh answers a new refresh token, with no grace period: a retry with a used refresh token ends the client's access, and the member connects it again. Store the new refresh token before you use the new access token. The token, refresh and revoke sections below are for apps an admin created.
Send the member's browser to the authorize URL with these query parameters:
GET https://attia.app/oauth/authorize| Name | Required | Description |
|---|---|---|
client_id | required | The app's client ID |
redirect_uri | required | One of the app's redirect URIs, exactly as registered |
response_type=code | required | The only response type Attia supports |
scope | optional | A comma-separated list of scopes. See Scopes. Left out, it is read |
state | optional, recommended | A random value. Attia sends it back unchanged to the redirect URI. Always send it |
code_challenge | required | The S256 challenge of your code verifier. See PKCE |
code_challenge_method=S256 | required | Attia accepts only S256 and refuses plain |
actor | optional | user, the default, or app. See Actor |
resource | optional | The API the token is for. Left out, it is https://attia.app/api/v1, the only value this API takes |
prompt | optional | Accepted, and changes nothing, because Attia shows the consent screen on every request |
A member who is not signed in signs in first and comes back to the same URL. The consent screen names the app and the permissions it asks for. The member chooses a workspace, then Approve or Cancel. When the workspace has third-party application review on and an admin has not approved your app there, Approve asks an admin instead, and your app gets no code until the member approves again after the admin does. The token is for the one workspace the member chose. To connect another workspace, send the member through authorize again.
PKCE
PKCE with S256 is required. Before each authorize request, make a new code verifier and keep it until you exchange the code. The challenge is the SHA-256 of the verifier, base64url-encoded without padding, which is 43 characters.
CODE_VERIFIER=$(openssl rand -hex 32)CODE_CHALLENGE=$(printf '%s' "$CODE_VERIFIER" \ | openssl dgst -sha256 -binary \ | openssl base64 -A \ | tr '+/' '-_' | tr -d '=')echo "$CODE_CHALLENGE"Example
https://attia.app/oauth/authorize?client_id=<client_id>&redirect_uri=https%3A%2F%2Fexample.com%2Foauth%2Fcallback&response_type=code&scope=read,write&state=<state>&code_challenge=<code_challenge>&code_challenge_method=S256Handle the redirect
After Approve, Attia sends the member to your redirect URI with a code and the state you sent. Check that state matches the value you sent. If it does not, do not trust the request.
GET https://example.com/oauth/callback?code=<code>&state=<state>The code works once. When the member chooses Cancel, or Attia refuses the request, the redirect carries error and error_description instead. See Errors.
Exchange the code for a token
Send the code to the token endpoint as a form, with Content-Type: application/x-www-form-urlencoded. Authenticate with the client ID and the client secret through HTTP Basic authentication.
POST https://attia.app/oauth/token| Name | Required | Description |
|---|---|---|
grant_type=authorization_code | required | |
code | required | The code from the redirect |
redirect_uri | required | The same redirect URI you used to authorize |
code_verifier | required | The code verifier you made the challenge from |
resource | optional | Left out, the token is for the resource the authorize request named |
curl https://attia.app/oauth/token \ -u "<client_id>:<client_secret>" \ -d grant_type=authorization_code \ -d "code=<code>" \ --data-urlencode "redirect_uri=https://example.com/oauth/callback" \ -d "code_verifier=<code_verifier>"The answer holds an access token and a refresh token. An access token starts with oat_ and works for 24 hours.
{ "access_token": "oat_...", "token_type": "bearer", "expires_in": 86400, "refresh_token": "<refresh_token>"}The answer can hold more fields, such as scope. scope there lists sign-in scopes, not the Attia scopes the member approved.
Make an API call
Send the access token in the Authorization header as a bearer token.
curl https://attia.app/api/v1/jobs \ -H "Authorization: Bearer <access_token>"An access token reads with GET and writes with POST, PATCH and DELETE, inside the scopes the member approved and the member's role now. Creating a job or changing one, writing, editing or deleting a comment or a job update, creating or changing a document, creating, changing, archiving or unarchiving a label, uploading an image and marking a notification need write. Moving or changing an application, updating a candidate or its labels, uploading a file and deleting a file on an application need candidates:write, and a comment on an application or a candidate needs it as well as write. Every webhook operation needs admin. A write through an app keeps the member as the actor, and the workspace's audit log reads <member> via <app>. An Idempotency-Key counts per app, so the same value sent by two apps, or by an app and an API key, makes two requests.
Call the API from a server, never from a web page. A token the API refuses gets invalid-api-key with status 401, whether it is unknown, expired or revoked, or the member left the workspace.
Each member can make 5,000 requests an hour through each app, and no more than 10 in one second. This count is separate from the member's API keys. Rate limits shows the headers and what to do over the limit.
Refresh a token
When the access token expires, send the refresh token to the token endpoint for a new pair, with the same Basic authentication.
| Name | Required | Description |
|---|---|---|
grant_type=refresh_token | required | |
refresh_token | required | The refresh token from the last answer |
resource | optional | Left out, the new token is for the same resource |
curl https://attia.app/oauth/token \ -u "<client_id>:<client_secret>" \ -d grant_type=refresh_token \ -d "refresh_token=<refresh_token>"Each refresh answers a new refresh token. Store it before you use the new access token. Using a refresh token has a 30-minute grace period for network errors. When no answer arrived, send the same request again with the same refresh token, and Attia answers the same new tokens. A second refresh that arrives while the first is still running waits up to 5 seconds for its answer.
After those 30 minutes the old refresh token gets invalid_grant, and the app's access ends. The member then approves the app again.
In one case the grace cannot help. When Attia passed the refresh on and lost the answer, the token endpoint answers 503, and the refresh token may already be used up. A retry after 60 seconds then gets invalid_grant, and the member approves the app again.
Revoke a token
To end the app's access, send a token in the token form field to the revocation endpoint, with the same Basic authentication. token_type_hint is optional, access_token or refresh_token.
POST https://attia.app/oauth/revokecurl -i https://attia.app/oauth/revoke \ -u "<client_id>:<client_secret>" \ -d "token=<access_token>" \ -d token_type_hint=access_tokenRevoking the access token also ends its refresh token. The API refuses the access token within 60 seconds.
The endpoint answers with one of these statuses:
200: the token was revoked. A token Attia does not know gets200too.400: the request has notoken, or no client authentication.401: the client ID or the client secret is wrong.429or503:temporarily_unavailable. Wait the seconds inRetry-Afterand send it again.
Scopes
Each scope is a permission the member approves on the consent screen. An app asks only for the scopes it needs.
| Scope | What it allows |
|---|---|
read | Read the workspace's jobs, statuses, labels and documents, with how many applications each job has in each status. Always present, whether or not the app asks for it |
write | Create and change jobs, documents and labels, write, edit and delete comments and job updates, upload images and mark notifications, as the member who approved the app |
admin | Read, create and delete the workspace's webhooks, while the member who approved is a workspace admin. Never ask for it unless the app needs it |
candidates:read | Read applications, candidates and the documents linked to them, while an admin lets the app read candidate data |
candidates:write | Move or change applications, update candidates and attach or remove their labels, book, move and cancel interviews and ask a candidate to choose a time, upload files and delete a file on an application, on the same terms. A comment on an application or a candidate needs this scope and write |
A call that needs a scope the member did not approve gets insufficient-scope.
Candidate data
An app reads candidate data only while two switches are on in a workspace on the Business or Enterprise plan. Both are off by default. Only an admin can turn them on, and on the Enterprise plan only a workspace owner:
- Candidate data in the API, under Settings → API, for every app and personal API key in the workspace.
- Turn on candidate data…, in the app's menu under Settings → Authorized applications, for that app alone. The app is listed there once a member has connected it or asked an admin to approve it.
Any app may ask for candidates:read and candidates:write, whether or not it registered them. While no admin has turned on candidate data for the app in the chosen workspace, the consent screen refuses the request after Approve, and Done sends access_denied back to the app. Once an admin turns it on, the member connects again.
The app sees only the applications and candidates the member who approved it can see. Turning either switch off, or moving to a lower plan, stops the app at once: a call that needs candidates:read gets insufficient-scope, and the app's other access stays.
Webhooks
An app can get the events of every workspace that installs it, at one URL. A workspace admin sets it up on the app's page under Settings → API:
- Turn on Webhooks.
- Webhook URL: the address every installing workspace sends its events to. It must start with
https://. - Data change events: Applications, Candidates and Jobs, as for a workspace webhook. Applications starts checked.
Then choose Create or Save changes. The first time webhooks go on, Attia shows the Webhook signing secret once, so copy it then. On a new app it shows with the client secret. Rotate secret makes a new one, and for 24 hours each delivery carries a signature from both.
A workspace that installs the app sends its events while it is on Business or Enterprise, and each delivery's workspace_id names that workspace. Application events go only while the workspace lets the app read candidate data. A job or application on a private team sends nothing. Each delivery reads the record as a member who installed the app and is still in the workspace, so it carries only what that member can see. That member needs read for a job event and candidates:read for an application event or candidate.erased.
The request, the signature and the retries work as for a workspace webhook. After 24 hours of failed deliveries from any installing workspace, Attia turns the app's webhooks off and tells the admins of the app's workspace by email and in the inbox. An admin turns them on again on the app's page. A workspace stops sending at once when no member there has the app installed any more, when an admin denies the app, or when the app is deleted, and a delivery already queued for it is not sent.
Actor
actor says who the app acts as.
user, the default: the app acts as the member who approved it. Use this when each member connects on their own.app: the app acts as itself. Only a workspace admin can approve it, and the consent screen shows the app's name under Acts as. An app withactor=appcannot ask foradmin.
The app reads and writes the same with either actor: it sees what the member who approved it can see, and each write names that member.
Errors
The API's own errors, such as insufficient-scope, plan-required and rate-limited, are on Errors. The OAuth endpoints answer with the codes below.
On the redirect
When the client ID is unknown, the redirect URI is not one of the app's, or either is sent more than once, Attia shows an error page and does not redirect. Every other refusal goes to the redirect URI with error, error_description and the state you sent.
Only the authorization server checks the redirect URI of a client whose client ID is a metadata document URL. So for that client every refusal in the table except access_denied shows the error page, and access_denied reaches the client through the authorization server.
error | When |
|---|---|
invalid_request | A parameter other than client_id, redirect_uri or resource is sent more than once, response_type or code_challenge is missing, code_challenge_method is not S256, code_challenge is not 43 base64url characters, or actor is not user or app |
unsupported_response_type | response_type is not code |
invalid_scope | A scope is not one of Attia's, the app may not ask for it, the resource does not offer it, or admin comes with actor=app |
invalid_target | resource is sent more than once, or is not one Attia issues tokens for |
access_denied | The member chose Cancel, is not a member of the chosen workspace, or asked for actor=app without being an admin. Also when the workspace is view-only or does not allow access from the member's network, is below Business and the token is for the API, or has not turned on candidate data for an app that asked for candidates:read or candidates:write |
From the token endpoint
An error answers JSON with error and error_description.
| Status | error | When |
|---|---|---|
| 400 | invalid_request | The body is not application/x-www-form-urlencoded, is larger than 16 KB, or a refresh repeats a parameter |
| 400 | invalid_grant | The code was used, or the code verifier does not match its challenge, which also uses up the code. Or the refresh token is unknown, revoked, or used more than 30 minutes ago |
| 400 | invalid_target | resource is sent more than once or is not one Attia issues tokens for, or a retried refresh names another resource than the first |
| 401 | invalid_client | The client authentication is wrong, or a retried refresh comes from another client than the first |
| 429 | temporarily_unavailable | More than 300 requests in a minute from your address. Wait the seconds in Retry-After |
| 503 | temporarily_unavailable | The token endpoint could not finish the request. Wait the seconds in Retry-After and send it again |
The revocation endpoint answers invalid_request, invalid_client and temporarily_unavailable in the same way.