> ## Documentation Index
> Fetch the complete documentation index at: https://docs.artbucket.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Trade a code for a token

> Form-encoded (or JSON). `authorization_code` with `code_verifier`, or the device code grant. The token is an API key bound to the person who consented: at most the scope they picked, never more than they can do. It lasts until revoked.

No key needed.



## OpenAPI

````yaml /openapi.json post /api/v1/oauth/token
openapi: 3.1.0
info:
  title: artbucket
  version: '1'
  description: >-
    Agent-first asset management. The web UI is built on this API and nothing
    else, beside signing in at /api/auth. Send `Authorization: Bearer <key>`: a
    key works in one workspace with one scope, and scopes are a ladder: read <
    propose < write < admin. People signed in to the app carry a session cookie
    instead, and their scope is what their grants add up to: on the
    organization, the workspace, or single collections and assets. A scope shown
    as needed on the workspace is also enough on the one collection or asset a
    route acts on. Agents (MCP at POST /api/v1/mcp) usually get `propose`: what
    they add waits for a human.
servers:
  - url: http://localhost:3000
security:
  - bearer: []
  - session: []
  - {}
paths:
  /api/v1/oauth/token:
    post:
      summary: Trade a code for a token
      description: >-
        Form-encoded (or JSON). `authorization_code` with `code_verifier`, or
        the device code grant. The token is an API key bound to the person who
        consented: at most the scope they picked, never more than they can do.
        It lasts until revoked.


        No key needed.
      responses:
        '200':
          description: The token
          content:
            application/json:
              schema:
                type: object
                properties:
                  access_token:
                    type: string
                  token_type:
                    type: string
                    const: Bearer
                  scope:
                    type: string
                    enum:
                      - propose
                      - read
                      - write
                required:
                  - access_token
                  - token_type
                  - scope
                additionalProperties: false
        default:
          description: An error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      detail: {}
                    required:
                      - code
                      - message
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
      security: []
components:
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: 'An API key: ab_...'
    session:
      type: apiKey
      in: cookie
      name: better-auth.session_token
      description: Signed in, at /api/auth

````