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

# Create a short-lived user session token

> Use your API key to mint a scoped, short-lived JWT for agent calls.



## OpenAPI

````yaml openapi.yaml post /partner/v1/sessions
openapi: 3.1.0
info:
  title: Machines Cash API
  version: 0.3.0
  description: >
    API for KYC, cards, encryption, balances, deposits, transactions, and
    withdrawals.

    All responses use a consistent envelope by default: { ok, data, summary,
    errors[], next }.

    Set X-Open-Responses: 1 to receive Open Responses-style response objects.
servers:
  - url: https://api.machines.cash
    description: production
  - url: https://dev-api.machines.cash
    description: sandbox
security: []
tags:
  - name: users
  - name: sessions
  - name: kyc
  - name: kycValues
  - name: agreements
  - name: cards
  - name: encryption
  - name: balances
  - name: deposits
  - name: transactions
  - name: withdrawals
paths:
  /partner/v1/sessions:
    parameters:
      - $ref: '#/components/parameters/OpenResponses'
      - $ref: '#/components/parameters/OpenResponsesCallId'
    post:
      tags:
        - sessions
      summary: Create a short-lived user session token
      description: Use your API key to mint a scoped, short-lived JWT for agent calls.
      operationId: api.sessions.create
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSessionRequest'
      responses:
        '201':
          description: Session created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateSessionResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
      security:
        - ApiKey: []
components:
  parameters:
    OpenResponses:
      name: X-Open-Responses
      in: header
      required: false
      schema:
        type: string
        enum:
          - '1'
          - 'true'
      description: >-
        Return Open Responses-compatible output when set (replaces the default
        response envelope).
    OpenResponsesCallId:
      name: X-Open-Responses-Call-Id
      in: header
      required: false
      schema:
        type: string
        minLength: 1
      description: >-
        Tool call id used for function_call_output items when Open Responses
        mode is enabled.
  schemas:
    CreateSessionRequest:
      type: object
      additionalProperties: false
      required:
        - userId
        - scopes
      properties:
        userId:
          type: string
          minLength: 1
          maxLength: 120
          description: Your user id (must match users.resolve).
          example: user-123
        walletAddress:
          $ref: '#/components/schemas/WalletAddress'
        scopes:
          type: array
          minItems: 1
          description: >-
            Scopes to grant to the session token. Deposits and balances do not
            require extra scopes.
          example:
            - kyc.read
            - kyc.write
          items:
            type: string
            enum:
              - users.read
              - users.write
              - kyc.read
              - kyc.write
              - cards.read
              - cards.write
              - cards.secrets.read
              - encryption.read
              - encryption.write
              - deposits.read
              - deposits.write
              - transactions.read
              - withdrawals.write
        ttlSeconds:
          type: integer
          minimum: 60
          maximum: 86400
          description: Time-to-live in seconds (default 900).
          example: 900
        sessionLabel:
          type: string
          maxLength: 120
          description: Optional label for auditing.
    CreateSessionResponse:
      type: object
      additionalProperties: false
      required:
        - ok
        - data
        - summary
        - errors
      properties:
        ok:
          type: boolean
          const: true
        data:
          $ref: '#/components/schemas/SessionToken'
        summary:
          type: string
        errors:
          type: array
          items:
            $ref: '#/components/schemas/ErrorDetail'
        next:
          $ref: '#/components/schemas/NextHint'
    WalletAddress:
      type: string
      pattern: ^0x[a-fA-F0-9]{40}$
      example: '0x2b0f7f2f7c8e4c3d2d3b3f6a8f9b0c1d2e3f4a5b'
    SessionToken:
      type: object
      additionalProperties: false
      required:
        - sessionToken
        - sessionId
        - userId
        - expiresAt
        - scopes
      properties:
        sessionToken:
          type: string
          description: Bearer token for agent calls.
        sessionId:
          type: string
        userId:
          type: string
          description: Your user id.
        expiresAt:
          type: string
          format: date-time
        scopes:
          type: array
          items:
            type: string
    ErrorDetail:
      type: object
      additionalProperties: false
      required:
        - code
        - message
      properties:
        code:
          type: string
          example: invalid_request
        message:
          type: string
          example: missing required field
        field:
          type: string
          description: Optional field name that caused the error.
    NextHint:
      type: object
      additionalProperties: false
      properties:
        pollAfterMs:
          type: integer
          minimum: 0
        suggestedTool:
          type: string
        suggestedArgs:
          type: object
          additionalProperties: true
    ErrorResponse:
      type: object
      additionalProperties: false
      required:
        - ok
        - summary
        - errors
      properties:
        ok:
          type: boolean
          const: false
        summary:
          type: string
          example: invalid request
        errors:
          type: array
          items:
            $ref: '#/components/schemas/ErrorDetail'
        next:
          $ref: '#/components/schemas/NextHint'
  responses:
    BadRequest:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Conflict:
      description: Conflict
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: X-Partner-Key

````