Token endpoint: install codes, partner links, Atlas operator token exchange

Embed
Preview of the card
<a href="https://referalli.com/docs/ref-postv1oauthtoken"><img src="https://referalli.com/docs/_api/public/orgs/07f432f4-34b9-46a7-aaad-c0e395d2e4f9/spaces/2bf4f614-3630-4fbf-85f9-5ecafa6b7d97/pages/08825332-7e77-4455-95c1-a4414e7b51f7/social-card.svg?v=3e7ae33eec8b" alt="Token endpoint: install codes, partner links, Atlas operator token exchange" width="600" height="315"></a>
POST https://referalli.com/v1/oauth/token

Form-encoded or JSON, three grants. authorization_code: the platform trades the single-use one-click-install code and its PKCE code_verifier for a new signed-protocol connection and its signing secret (returned only here), plus a one-hour access_token scoped connections:write webhooks:write so the platform can require v2 signatures and register its sync webhook; installing again keeps the connection and issues a new secret, the old one verifying for 24 hours; 401 for an unknown, used, expired or mismatched code. client_credentials: a partner link's client_id and client_secret (HTTP Basic or the body), optional scope within the link's, for a one-hour rat_… bearer token. urn:ietf:params:oauth:grant-type:token-exchange (RFC 8693): subject_token = an Atlas operator access token from atlas login (issuer https://atlasauth.net, verified with its discovery document and JWKS, scope atlas:operator), subject_token_type access_token, resource = the org id; the Atlas account must sign in to a Referalli member of that org, and the token gets that role (owner: admin, admin: full, others: read), narrowed by scope. Errors follow RFC 6749 §5.2 ({error, error_description}). No authentication.

Auth: none.

Request body

application/json
Example
{
  "grant_type": "string",
  "code": "string",
  "code_verifier": "string",
  "client_id": "string",
  "redirect_uri": "string"
}
Option 1
grant_type
string
required
code
string
required
code_verifier
string
required
client_id
string
required
redirect_uri
string
required
{
  "grant_type": "string",
  "code": "string",
  "code_verifier": "string",
  "client_id": "string",
  "redirect_uri": "string"
}
Option 2
grant_type
string
required
client_id
string
client_secret
string
scope
string
{
  "grant_type": "string",
  "client_id": "string",
  "client_secret": "string",
  "scope": "string"
}
Option 3
grant_type
string
required
subject_token
string
required
subject_token_type
string
required
requested_token_type
string
audience
string
resource
string
required
The Referalli org id the token is for.
scope
string
{
  "grant_type": "string",
  "subject_token": "string",
  "subject_token_type": "string",
  "requested_token_type": "string",
  "audience": "string",
  "resource": "string",
  "scope": "string"
}

Code samples

cURL
curl -X POST "https://referalli.com/v1/oauth/token" \
  -H "Content-Type: application/json" \
  -d '{"grant_type":"string","code":"string","code_verifier":"string","client_id":"string","redirect_uri":"string"}'
TypeScript
Python
Go
PHP
Ruby
Java

Responses

200 OK
Example
{
  "token_type": "string",
  "connectionId": "string",
  "provider": "string",
  "instanceId": "string",
  "programId": "string",
  "secret": "string",
  "reinstalled": true,
  "signupsUrl": "string",
  "partnersUrl": "string",
  "eraseUrl": "string",
  "exportUrl": "string",
  "access_token": "string",
  "expires_in": 0,
  "scope": "string"
}
Option 1
token_type
string
required
connectionId
string
required
provider
string
required
instanceId
string
required
programId
string
required
secret
string
required
The connection signing secret. Returned only here.
reinstalled
boolean
required
signupsUrl
string
required
partnersUrl
string
required
eraseUrl
string
required
exportUrl
string
required
access_token
string
required
A one-hour rat_… token for this org, scoped connections:write webhooks:write: require v2 signatures and register the sync webhook.
expires_in
integer
required
scope
string
required
{
  "token_type": "string",
  "connectionId": "string",
  "provider": "string",
  "instanceId": "string",
  "programId": "string",
  "secret": "string",
  "reinstalled": true,
  "signupsUrl": "string",
  "partnersUrl": "string",
  "eraseUrl": "string",
  "exportUrl": "string",
  "access_token": "string",
  "expires_in": 0,
  "scope": "string"
}
Option 2
access_token
string
required
A one-hour rat_… bearer token (client_credentials or token exchange, REF-S28).
token_type
string
required
expires_in
integer
required
scope
string
required
issued_token_type
string
resource
string
{
  "access_token": "string",
  "token_type": "string",
  "expires_in": 0,
  "scope": "string",
  "issued_token_type": "string",
  "resource": "string"
}
400 The request is invalid. error.code is one of:
Example
{
  "error": {
    "code": "validation_error",
    "message": "the body or query failed validation, an unknown field was sent, the body is not valid json, or a session call has no `x-org-id`",
    "details": [
      {
        "code": "invalid_format",
        "path": [
          "destinationUrl"
        ],
        "message": "Invalid URL"
      }
    ],
    "docs_url": "https://referalli.com/docs/errors-and-limits#validation_error"
  }
}
Schema
error
object
required
Show child parameters
code
string
required
message
string
required
details
requestId
string
docs_url
string
required
The docs entry for this error code: what it means and how to fix it.
Headers
x-request-id
string
This request's id (req_…), matching the server logs. On every response.
404 No such resource. error.code is one of:
Example
{
  "error": {
    "code": "not_found",
    "message": "the resource does not exist in this org (ids from other orgs look the same), a referenced id does not exist, a list cursor is not in the list, or the endpoint does not exist",
    "docs_url": "https://referalli.com/docs/errors-and-limits#not_found"
  }
}
Schema
error
object
required
Show child parameters
code
string
required
message
string
required
details
requestId
string
docs_url
string
required
The docs entry for this error code: what it means and how to fix it.
Headers
x-request-id
string
This request's id (req_…), matching the server logs. On every response.
429 Rate limited. error.code is one of:
Example
{
  "error": {
    "code": "rate_limited",
    "message": "an endpoint limit or the per-key quota was exceeded",
    "docs_url": "https://referalli.com/docs/errors-and-limits#rate_limited"
  }
}
Schema
error
object
required
Show child parameters
code
string
required
message
string
required
details
requestId
string
docs_url
string
required
The docs entry for this error code: what it means and how to fix it.
Headers
x-request-id
string
This request's id (req_…), matching the server logs. On every response.
Retry-After
integer
Seconds until a retry can succeed.
RateLimit-Limit
integer
The quota bucket's size (the burst).
RateLimit-Remaining
integer
Requests that can be made right now.
RateLimit-Reset
integer
Seconds until the bucket is full again.
500 Unexpected server error. error.code is one of:
Example
{
  "error": {
    "code": "internal_error",
    "message": "retry with backoff",
    "requestId": "req_8f2c1d4e5a6b7c8d",
    "docs_url": "https://referalli.com/docs/errors-and-limits#internal_error"
  }
}
Schema
error
object
required
Show child parameters
code
string
required
message
string
required
details
requestId
string
docs_url
string
required
The docs entry for this error code: what it means and how to fix it.
Headers
x-request-id
string
This request's id (req_…), matching the server logs. On every response.
default Any other error, in the same envelope.
Example
{
  "error": {
    "code": "string",
    "message": "string",
    "details": {},
    "requestId": "string",
    "docs_url": "string"
  }
}
Schema
error
object
required
Show child parameters
code
string
required
message
string
required
details
requestId
string
docs_url
string
required
The docs entry for this error code: what it means and how to fix it.
Updated