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

# Self-register and mint an API key

> Create an account and mint an API key in a single unauthenticated
call — no login required. The account is granted the standard signup
credit and the plaintext API key is returned **exactly once** (it is
hashed at rest and cannot be retrieved again — store it securely).
Send the returned key as the `x-api-key` header on `/api/v1/*`
requests. Rate limited per client IP.




## OpenAPI

````yaml https://gateway.sanfoundation.com/openapi.yaml post /api/v1/register
openapi: 3.1.0
info:
  title: SAN Foundation Gateway API
  version: 1.0.0
  description: |
    Public API for the SAN Foundation gateway. The same data is exposed
    through two interchangeable surfaces: `/api/v1/*` is authenticated
    with an `x-api-key` (`sk_…`) and billed in credits (per-call cost
    in `x-credits`); `/x402/v1/*` is paid per call in USDC over the
    [x402 protocol](https://x402.org) and requires no API key (per-call
    cost in `x-price-usd`).
servers:
  - url: https://gateway.sanfoundation.com
    description: Production
security: []
tags:
  - name: API Key
    description: |
      Operations under `/api/v1/*`. Authenticate with a SAN API key
      (`x-api-key` header) and pay with prepaid credits — see each
      operation's `x-credits` for the per-call cost.
  - name: x402
    description: |
      Operations under `/x402/v1/*`. Pay per call in USDC over the
      [x402 protocol](https://x402.org) — see each operation's
      `x-price-usd` for the per-call cost. No API key required.
  - name: Registration
    description: |
      Public, unauthenticated self-onboarding for agents. One call mints an
      API key and grants the signup credit so an agent can immediately use
      `/api/v1/*`. Rate limited per client IP.
paths:
  /api/v1/register:
    post:
      tags:
        - Registration
      summary: Self-register and mint an API key
      description: |
        Create an account and mint an API key in a single unauthenticated
        call — no login required. The account is granted the standard signup
        credit and the plaintext API key is returned **exactly once** (it is
        hashed at rest and cannot be retrieved again — store it securely).
        Send the returned key as the `x-api-key` header on `/api/v1/*`
        requests. Rate limited per client IP.
      operationId: registerAgent
      responses:
        '201':
          $ref: '#/components/responses/RegistrationOk'
        '429':
          $ref: '#/components/responses/TooManyRegistrations'
components:
  responses:
    RegistrationOk:
      description: OK — account registered and API key minted (key shown once).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RegisterResponse'
    TooManyRegistrations:
      description: |
        Too many registrations from this client IP. The endpoint allows a
        limited number of registrations per hour and per day per IP; retry
        after the window resets.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Too many registrations from this IP. Please try again later.
  schemas:
    RegisterResponse:
      type: object
      required:
        - apiKey
        - balance
      properties:
        apiKey:
          type: string
          description: |
            Plaintext API key (`sk_…`). Returned once and never retrievable
            again — store it securely. Send as the `x-api-key` header on
            `/api/v1/*` requests.
        balance:
          type: string
          description: Granted spendable balance in dollars (e.g. "100.00").
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
        ref:
          type: string
          description: Echoed back when an agent ref could not be resolved.
        eventId:
          type: string
          description: Echoed back when an event id could not be resolved.
        min:
          type: integer
          description: Echoed back on a `limit out of range` error.
        max:
          type: integer
          description: Echoed back on a `limit out of range` error.

````