Rokha Auth API

Google sign-in and session refresh

GitHub OpenAPI

Operations 7

POST /api/auth/cli/authorize Authorize a CLI device by user_code #
POST /api/auth/cli/poll Poll for device-flow authorization #
POST /api/auth/cli/start Start a CLI device-flow authorization #
GET /api/auth/google/callback Google OAuth callback #
POST /api/auth/google/start Begin Google OAuth flow #
POST /api/auth/logout Revoke the presented token #
POST /api/auth/refresh Refresh an expiring JWT #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/rokha-ai:rokha-ai-auth-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

rokha-ai-auth-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  contact:
    name: Rokha
    url: https://rokha.ai
  description: 'The public API of Rokha, the Agent Lab. Build a tool,

    run it for real with a trace, sell it or hire it out. Agents use the same

    doors over MCP at `/mcp/jsonrpc`. Versioning: `GET /api/schema/version`.'
  license:
    name: MIT
    url: https://github.com/rokha-ai/rokha-sdk/blob/main/LICENSE
  title: Rokha Public Auth API
  version: 1.0.0
servers:
- description: Local development (default Erebus port)
  url: http://localhost:3000
- description: Production (hosted Erebus)
  url: https://erebus.rokha.ai
security: []
tags:
- description: Google sign-in and session refresh
  name: Auth
paths:
  /api/auth/cli/authorize:
    post:
      description: 'JWT-required. Called from the rokha.ai `/cli` page after the

        user has logged in. Binds the `user_code` to the caller''s

        identity, mints a CLI-scoped 30-day JWT, and stores it for the

        CLI''s next poll.'
      operationId: cliAuthAuthorize
      requestBody:
        content:
          application/json:
            schema:
              properties:
                user_code:
                  example: ABCD-1234
                  type: string
              required:
              - user_code
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CliDeviceAuthorizeResponse'
          description: Code bound to identity; CLI poll will now return JWT
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unknown user_code
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Code already authorized or denied
        '410':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Code expired
      security:
      - bearerAuth: []
      summary: Authorize a CLI device by user_code
      tags:
      - Auth
  /api/auth/cli/poll:
    post:
      description: 'Anonymous. The CLI polls every `interval` seconds with its

        `device_code`. Returns `pending`, `slow_down`, `authorized`

        (with JWT), `expired`, or `denied`.'
      operationId: cliAuthPoll
      requestBody:
        content:
          application/json:
            schema:
              properties:
                device_code:
                  type: string
              required:
              - device_code
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CliDevicePollResponse'
          description: Poll outcome
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unknown device_code
      summary: Poll for device-flow authorization
      tags:
      - Auth
  /api/auth/cli/start:
    post:
      description: 'Anonymous. The CLI calls this to obtain a `device_code` (opaque,

        kept private) + `user_code` (short, shown to the user). The user

        completes the flow at `verification_uri` in a browser.'
      operationId: cliAuthStart
      requestBody:
        content:
          application/json:
            schema:
              properties:
                client:
                  description: Self-reported client identifier (e.g. `ro/0.2.0`).
                  type: string
                scope:
                  default: cli
                  type: string
              type: object
        required: false
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CliDeviceStartResponse'
          description: Device flow initiated
      summary: Start a CLI device-flow authorization
      tags:
      - Auth
  /api/auth/google/callback:
    get:
      operationId: googleAuthCallback
      parameters:
      - in: query
        name: code
        required: true
        schema:
          type: string
      - in: query
        name: state
        required: true
        schema:
          type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthSuccessResponse'
          description: Authenticated
      summary: Google OAuth callback
      tags:
      - Auth
  /api/auth/google/start:
    post:
      description: Returns the URL the client should redirect to.
      operationId: googleAuthStart
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  redirect_url:
                    format: uri
                    type: string
                  state:
                    type: string
                type: object
          description: OAuth start URL
      summary: Begin Google OAuth flow
      tags:
      - Auth
  /api/auth/logout:
    post:
      description: 'Revokes the bearer token you send, server-side. Idempotent — always

        answers 200, whether or not the token was already revoked or expired.'
      operationId: authLogout
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  success:
                    type: boolean
                type: object
          description: Token revoked (or already was)
      security:
      - bearerAuth: []
      summary: Revoke the presented token
      tags:
      - Auth
  /api/auth/refresh:
    post:
      operationId: authRefresh
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthSuccessResponse'
          description: Refreshed
        '401':
          $ref: '#/components/responses/Unauthorized'
      security:
      - bearerAuth: []
      summary: Refresh an expiring JWT
      tags:
      - Auth
components:
  schemas:
    CliDeviceAuthorizeResponse:
      properties:
        device_summary:
          properties:
            client:
              nullable: true
              type: string
            created_at:
              format: date-time
              type: string
          required:
          - created_at
          type: object
        status:
          enum:
          - ok
          type: string
      required:
      - status
      - device_summary
      type: object
    CliDevicePollResponse:
      discriminator:
        propertyName: status
      oneOf:
      - properties:
          status:
            enum:
            - pending
            type: string
        required:
        - status
        type: object
      - properties:
          interval:
            type: integer
          status:
            enum:
            - slow_down
            type: string
        required:
        - status
        - interval
        type: object
      - properties:
          identity:
            properties:
              auth_method:
                type: string
              identity:
                type: string
              tier:
                enum:
                - free
                - casual
                - pro
                type: string
              user_id:
                type: string
            required:
            - user_id
            - identity
            - auth_method
            - tier
            type: object
          jwt:
            description: 30-day CLI-scoped JWT
            type: string
          status:
            enum:
            - authorized
            type: string
        required:
        - status
        - jwt
        - identity
        type: object
      - properties:
          status:
            enum:
            - expired
            type: string
        required:
        - status
        type: object
      - properties:
          status:
            enum:
            - denied
            type: string
        required:
        - status
        type: object
    CliDeviceStartResponse:
      properties:
        device_code:
          description: 64-char hex. Never shown to the user. CLI uses this to poll.
          type: string
        expires_in:
          description: Seconds until the device_code expires.
          example: 600
          type: integer
        interval:
          description: Minimum seconds the CLI should wait between polls.
          example: 3
          type: integer
        user_code:
          description: 8 alphanumeric chars formatted `XXXX-XXXX` from a no-ambiguity alphabet.
          example: ABCD-1234
          type: string
        verification_uri:
          example: https://rokha.ai/cli
          format: uri
          type: string
        verification_uri_complete:
          description: Same as `verification_uri` but with `?code=user_code` so the user can skip the typing step.
          example: https://rokha.ai/cli?code=ABCD-1234
          format: uri
          type: string
      required:
      - device_code
      - user_code
      - verification_uri
      - verification_uri_complete
      - expires_in
      - interval
      type: object
    ErrorResponse:
      properties:
        code:
          type: string
        error:
          description: Machine-readable error code
          type: string
        message:
          type: string
        name:
          type: string
      required:
      - error
      type: object
    AuthSuccessResponse:
      properties:
        email_verified:
          type: boolean
        expires_at:
          format: date-time
          type: string
        success:
          type: boolean
        tier:
          enum:
          - free
          - casual
          - pro
          type: string
        token:
          description: JWT — store in sessionStorage as nb_session
          type: string
        user_id:
          format: uuid
          type: string
      required:
      - success
      - token
      type: object
  responses:
    Unauthorized:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: Missing or invalid auth
  securitySchemes:
    bearerAuth:
      bearerFormat: JWT
      description: 'JWT issued by `/api/wallets/verify` (after `/api/wallets/challenge`),

        or `/api/auth/google/callback`. Send as

        `Authorization: Bearer <token>`. Refresh via `/api/auth/refresh`

        before expiry (24h default).

        '
      scheme: bearer
      type: http