Sourced
llms.txt
View Markdown

Api Keys ยท version 0.1.0

Create a workspace API key

POST/api/api-keys

Creates a programmatic bearer token. The `token` is returned once and Sourced stores only a hash.

Request

cURL
curl -X POST 'https://sourced.sh/api/api-keys' \
  -H 'Authorization: Bearer $SOURCED_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{}'
TypeScript
const response = await fetch("https://sourced.sh/api/api-keys", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SOURCED_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({}),
});
const data = await response.json();
Python
import os
import requests

response = requests.request(
    "POST",
    "https://sourced.sh/api/api-keys",
    headers={"Authorization": f"Bearer {os.environ['SOURCED_API_KEY']}"},
    json={},
)
data = response.json()

Request body

application/json

Schema
ApiKeyCreateInput:
  type: object
  properties:
    name: string
    scopes: array
      Optional API key scopes. When omitted, Sourced creates a narrow key with `workspace:read`, `projects:write`, `runs:write`, and `artifacts:read`. Enforced public scopes include `workspace:read`, `projects:write`, `runs:write`, `artifacts:read`, `artifacts:write`, `api_keys:read`, `api_keys:write`, `billing:write`, `notifications:read`, `notifications:write`, `domains:read`, `domains:write`, `members:read`, `members:write`, `publishing:dry_run`, and `publishing:write`.
      type: array
      description: Optional API key scopes. When omitted, Sourced creates a narrow key with `workspace:read`, `projects:write`, `runs:write`, and `artifacts:read`. Enforced public scopes include `workspace:read`, `projects:write`, `runs:write`, `artifacts:read`, `artifacts:write`, `api_keys:read`, `api_keys:write`, `billing:write`, `notifications:read`, `notifications:write`, `domains:read`, `domains:write`, `members:read`, `members:write`, `publishing:dry_run`, and `publishing:write`.

Responses

201

API key created.

application/json

Schema
type: object
required: apiKey, token
properties:
  apiKey (required): ApiKey
    ApiKey:
      type: object
      required: id, name, tokenPrefix, scopes, createdAt
      properties:
        id (required): string
        orgId: string
        createdByUserId: string
        name (required): string
        tokenPrefix (required): string
          Non-secret token prefix for display and support.
        scopes (required): array
          type: array
        lastUsedAt: string
        revokedAt: string
        createdAt (required): string
        updatedAt: string
  token (required): string
    Secret bearer token, shown once.

401

403

Was this helpful?