Using the API

Authentication

Create API keys, send them as bearer tokens and keep them safe.

Every request needs an API key. Keys belong to an organization and a workspace, and usage made with a key is billed to that organization. Send the key in the Authorization header as a bearer token.

Header
Authorization: Bearer $SEOSORTED_API_KEY

Create a key

  1. Open Settings, API keys in the console.
  2. Choose Create key and give it a name you will recognize, such as the app and environment.
  3. Copy the key. It starts with sk-sorted- and is shown only once.

Test the key

Listing models is the quickest way to check a key. It costs nothing.

curl https://api.seosorted.ai/v1/models \
  -H "Authorization: Bearer $SEOSORTED_API_KEY"

Keep keys safe

  • Store keys in environment variables or a secret manager, never in source control.
  • Do not ship keys in browser or mobile code. Call the API from your server.
  • Use a separate key for each app and environment so you can revoke one without affecting the others.

If a key leaks

Revoke it right away from the API keys page, then create a new one. Requests with a revoked key fail with a 401 error immediately.

Authentication errors

A missing, malformed or revoked key returns status 401.

401 Unauthorized
{
  "error": {
    "message": "Incorrect API key provided.",
    "type": "invalid_request_error",
    "param": null,
    "code": "invalid_api_key"
  }
}