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

# Claim a spend intent

> Returns the card details for an approved spend intent. Call it from your trusted browser worker immediately before entering the card at checkout.

The card number and security code are stand-ins: the returned proxy replaces them with the real card details only on requests to `allowed_hosts`. Never put the response in model prompts, logs, recordings, or ordinary job storage.

Requires the agent secret key that created the intent, with `spend:write`, and an empty JSON body. After `claim_in_progress`, wait for `Retry-After` and retry with the same `Idempotency-Key`. A retry never extends `expires_at`. If the status becomes `issuance_unknown`, stop the purchase and don't create a replacement automatically.



## OpenAPI

````yaml /openapi/spend.json post /v1/spend_intents/{id}/claim
openapi: 3.0.3
info:
  title: Ionic Spend (preview)
  version: 0.1.0-preview
  description: >-
    Spend lets an agent use a business card for a purchase the business
    approves. Amounts are in the smallest currency unit and timestamps are Unix
    seconds. For the full flow, see Build browser purchases with Spend in the
    Ionic docs.
servers:
  - url: https://api.ionicfi.com
    description: Use the API origin Ionic provides for your enabled environment.
security:
  - secretKey: []
paths:
  /v1/spend_intents/{id}/claim:
    post:
      summary: Claim a spend intent
      description: >-
        Returns the card details for an approved spend intent. Call it from your
        trusted browser worker immediately before entering the card at checkout.


        The card number and security code are stand-ins: the returned proxy
        replaces them with the real card details only on requests to
        `allowed_hosts`. Never put the response in model prompts, logs,
        recordings, or ordinary job storage.


        Requires the agent secret key that created the intent, with
        `spend:write`, and an empty JSON body. After `claim_in_progress`, wait
        for `Retry-After` and retry with the same `Idempotency-Key`. A retry
        never extends `expires_at`. If the status becomes `issuance_unknown`,
        stop the purchase and don't create a replacement automatically.
      operationId: spend_intents_claim
      parameters:
        - $ref: '#/components/parameters/IonicAccount'
        - $ref: '#/components/parameters/IdempotencyKey'
        - $ref: '#/components/parameters/IntentID'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmptyRequest'
      responses:
        '200':
          description: The card details for checkout. Keep this response private.
          headers:
            Cache-Control:
              description: Always no-store, including errors and claim retries.
              schema:
                type: string
                enum:
                  - no-store
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SpendClaim'
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          $ref: '#/components/responses/404'
        '409':
          description: >-
            Retry `claim_in_progress` with the same key after `Retry-After`.
            Don't retry other conflicts.
          headers:
            Cache-Control:
              description: Always no-store, including errors and claim retries.
              schema:
                type: string
                enum:
                  - no-store
            Retry-After:
              description: Present only for claim_in_progress.
              schema:
                type: integer
                minimum: 1
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SpendError'
        '422':
          $ref: '#/components/responses/422'
        '429':
          $ref: '#/components/responses/429'
        '503':
          $ref: '#/components/responses/503'
components:
  parameters:
    IonicAccount:
      name: Ionic-Account
      in: header
      required: false
      schema:
        $ref: '#/components/schemas/AccountID'
      description: >-
        Required for delegated Connect requests; omit for direct business
        requests. Selector is not authorization.
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: true
      schema:
        type: string
        minLength: 16
        maxLength: 255
        pattern: ^[\x21-\x7e]+$
      description: >-
        Stable opaque key. Same body/key retries only. Claim key is bound
        permanently to the intent issuance; no second key can remint.
    IntentID:
      name: id
      in: path
      required: true
      schema:
        $ref: '#/components/schemas/IntentID'
  schemas:
    EmptyRequest:
      type: object
      additionalProperties: false
      properties: {}
    SpendClaim:
      type: object
      additionalProperties: false
      properties:
        spend_intent_id:
          $ref: '#/components/schemas/IntentID'
        card:
          type: object
          additionalProperties: false
          properties:
            number:
              type: string
              pattern: ^[0-9]{13,19}$
              description: Format-preserving stand-in, never plaintext PAN.
            cvc:
              type: string
              pattern: ^([0-9]{3,4})?$
              description: >-
                Short-lived stand-in, never plaintext CVC. Empty when the
                qualified checkout does not require CVC.
            exp_month:
              type: integer
              minimum: 1
              maximum: 12
            exp_year:
              type: integer
              minimum: 2000
              maximum: 9999
            holder_name:
              type: string
              minLength: 1
              maxLength: 200
              pattern: .*\S.*
          required:
            - number
            - cvc
            - exp_month
            - exp_year
            - holder_name
        billing_details:
          $ref: '#/components/schemas/BillingDetails'
        proxy:
          type: object
          additionalProperties: false
          properties:
            protocol:
              type: string
              enum:
                - https
            host:
              type: string
              pattern: ^[a-z0-9.-]+$
            port:
              type: integer
              minimum: 443
              maximum: 443
            username:
              type: string
              minLength: 1
              maxLength: 255
              pattern: .*\S.*
            password:
              type: string
              minLength: 1
              maxLength: 65536
              writeOnly: false
              description: >-
                Bearer secret. Never log, persist in general storage, or expose
                to model prompts.
            ca_bundle_url:
              type: string
              format: uri
              pattern: ^https://[^/\s]+
              description: >-
                HTTPS location of the proxy CA bundle. Use the URL returned in
                this claim response.
          required:
            - protocol
            - host
            - port
            - username
            - password
            - ca_bundle_url
        allowed_hosts:
          $ref: '#/components/schemas/AllowedHosts'
        browser_requirements:
          type: object
          additionalProperties: false
          properties:
            reload_payment_page:
              type: boolean
          required:
            - reload_payment_page
        expires_at:
          $ref: '#/components/schemas/Timestamp'
      required:
        - spend_intent_id
        - card
        - billing_details
        - proxy
        - allowed_hosts
        - browser_requirements
        - expires_at
      description: >-
        One protected bundle per intent. Original key recovers the exact same
        values until original expiry while currently authorized. No refreshed
        TTL. Generic idempotency caches must never store this response.
    SpendError:
      type: object
      additionalProperties: false
      properties:
        error:
          type: object
          additionalProperties: false
          properties:
            code:
              type: string
              minLength: 1
              maxLength: 100
              pattern: .*\S.*
            message:
              type: string
              minLength: 1
              maxLength: 1000
              pattern: .*\S.*
            retryable:
              type: boolean
            spend_intent:
              allOf:
                - $ref: '#/components/schemas/SpendIntent'
              description: 'Present only on limit_exceeded: the saved, blocked request.'
          required:
            - code
            - message
            - retryable
      required:
        - error
      description: >-
        Existing Ionic error envelope. Spend errors always include retryable.
        Authentication/Connect middleware retains its existing envelope and may
        omit retryable.
    AccountID:
      type: string
      pattern: ^mer_[A-Za-z0-9]{14}$
    IntentID:
      type: string
      pattern: ^spi_[A-Za-z0-9]{14}$
    BillingDetails:
      type: object
      additionalProperties: false
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 200
          pattern: .*\S.*
        email:
          type: string
          format: email
          maxLength: 254
        address:
          $ref: '#/components/schemas/Address'
      required:
        - name
        - address
    AllowedHosts:
      type: array
      minItems: 1
      maxItems: 20
      uniqueItems: true
      items:
        type: string
        maxLength: 253
        pattern: >-
          ^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+$
        not:
          anyOf:
            - pattern: ^[0-9.]+$
            - pattern: \.(local|internal|localhost)$
      description: >-
        Exact plaintext reveal destinations. Supply 1-20 distinct lowercase
        public DNS hosts on create to avoid seller pre-registration. Null,
        empty, wildcard, URL, port, path, IP and local/internal names are
        rejected. The actual hosts are customer-approved and immutable;
        redirects do not expand them. Not a whole-browser network allowlist,
        merchant-legitimacy check, or merchant-account/amount constraint.
    Timestamp:
      type: integer
      minimum: 0
      description: Unix epoch seconds. Equality with a deadline is expired.
      format: int64
    BoundaryError:
      type: object
      additionalProperties: false
      properties:
        error:
          type: object
          additionalProperties: false
          properties:
            code:
              type: string
              minLength: 1
              maxLength: 100
              pattern: .*\S.*
            message:
              type: string
              minLength: 1
              maxLength: 1000
              pattern: .*\S.*
            retryable:
              type: boolean
          required:
            - code
            - message
      required:
        - error
    SpendIntent:
      type: object
      additionalProperties: false
      properties:
        id:
          $ref: '#/components/schemas/IntentID'
        object:
          type: string
          enum:
            - spend_intent
        account_id:
          $ref: '#/components/schemas/AccountID'
        agent_id:
          $ref: '#/components/schemas/AgentID'
        livemode:
          type: boolean
        version:
          type: integer
          minimum: 1
        action:
          type: string
          enum:
            - payment
            - save_card
            - replace_card
        card_id:
          $ref: '#/components/schemas/CardID'
        purpose:
          type: string
          minLength: 1
          maxLength: 1000
          pattern: .*\S.*
        seller:
          $ref: '#/components/schemas/Seller'
        amount:
          type: integer
          minimum: 0
          maximum: 9007199254740991
        currency:
          type: string
          pattern: ^[a-z]{3}$
        billing_details:
          $ref: '#/components/schemas/BillingDetails'
        reference:
          type: string
          minLength: 1
          maxLength: 200
          pattern: .*\S.*
          nullable: true
        status:
          $ref: '#/components/schemas/SpendStatus'
        allowed_hosts:
          $ref: '#/components/schemas/AllowedHosts'
        approval_url:
          type: string
          minLength: 10
          maxLength: 2048
          pattern: ^https://[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?(?:/[^\s?#]*)?$
          description: >-
            Absolute HTTPS URL; no userinfo, port, query, fragment or
            whitespace. Return destinations require registration where
            specified. Seller pre-registration is not required when the caller
            supplies allowed_hosts.
          nullable: true
        return_url:
          type: string
          minLength: 10
          maxLength: 2048
          description: >-
            Where a platform's Agent asked the owner be returned after deciding:
            an absolute URL on one of the platform's approved origins, or null.
            The Ionic approval page sends the owner there with
            spend_intent={id}; the redirect is not proof of the decision, so
            read the intent. Only a platform's delegated Agent can set it.
          nullable: true
        created:
          $ref: '#/components/schemas/Timestamp'
        approval_expires_at:
          description: >-
            Server-selected deadline for the owner to approve a pending intent,
            in Unix seconds. This deadline does not shorten a claim window that
            starts after approval.
          allOf:
            - $ref: '#/components/schemas/Timestamp'
        approved_at:
          type: integer
          minimum: 0
          description: Unix epoch seconds. Equality with a deadline is expired.
          format: int64
          nullable: true
        claimed_at:
          type: integer
          minimum: 0
          description: Unix epoch seconds. Equality with a deadline is expired.
          format: int64
          nullable: true
        canceled_at:
          type: integer
          minimum: 0
          description: Unix epoch seconds. Equality with a deadline is expired.
          format: int64
          nullable: true
        claim_expires_at:
          type: integer
          minimum: 0
          description: >-
            approved_at + claim_within_seconds, in Unix seconds; null before
            approval. Preserve the original deadline in later states. It is
            independent of the pending-approval deadline; same-key recovery
            after this deadline remains subject to original credential expiry
            and current authority.
          format: int64
          nullable: true
        credential_expires_at:
          type: integer
          minimum: 0
          description: Unix epoch seconds. Equality with a deadline is expired.
          format: int64
          nullable: true
        claim_replay_available:
          type: boolean
        credential_exposure:
          type: string
          enum:
            - none
            - possible
            - issued
        claim_within_seconds:
          $ref: '#/components/schemas/ClaimWithinSeconds'
        approvals:
          type: array
          minItems: 0
          maxItems: 3
          items:
            $ref: '#/components/schemas/SpendApproval'
          description: >-
            Every required human approval, in decision order. The card owner's
            approval (business, or owner for a direct Agent) is always present
            and decides last, except on a blocked request (decision 0110), which
            no one can decide: there the list is empty.
        limit_breaches:
          type: array
          maxItems: 30
          items:
            $ref: '#/components/schemas/SpendLimitBreach'
          description: >-
            Limits exceeded when evaluated; empty when within every limit.
            Budgets cap approvals, not merchant charges.
        blocked_at:
          type: integer
          minimum: 0
          format: int64
          nullable: true
          description: >-
            When a blocking limit rule ended the request, in Unix seconds: at
            creation or at the final approval (decision 0110). Null on every
            other status.
      required:
        - id
        - object
        - account_id
        - agent_id
        - livemode
        - version
        - action
        - card_id
        - purpose
        - seller
        - amount
        - currency
        - billing_details
        - reference
        - status
        - allowed_hosts
        - approval_url
        - return_url
        - created
        - approval_expires_at
        - approved_at
        - claimed_at
        - canceled_at
        - claim_expires_at
        - credential_expires_at
        - claim_replay_available
        - credential_exposure
        - claim_within_seconds
        - approvals
        - limit_breaches
        - blocked_at
      description: >-
        Credential/approval state, never merchant payment status. Unknown
        issuance preserves credential_exposure=possible even after cancellation.
        Null credential_expires_at means no verified expiry is known, not that
        exposure ended.
    Address:
      type: object
      additionalProperties: false
      properties:
        line1:
          type: string
          minLength: 1
          maxLength: 200
          pattern: .*\S.*
        line2:
          type: string
          maxLength: 200
        city:
          type: string
          minLength: 1
          maxLength: 100
          pattern: .*\S.*
        state:
          type: string
          maxLength: 100
        postal_code:
          type: string
          minLength: 1
          maxLength: 32
          pattern: .*\S.*
        country:
          type: string
          pattern: ^[A-Z]{2}$
      required:
        - line1
        - city
        - postal_code
        - country
    AgentID:
      type: string
      pattern: ^agt_[A-Za-z0-9]{14}$
    CardID:
      type: string
      pattern: ^spcard_[A-Za-z0-9]{14}$
    Seller:
      type: object
      additionalProperties: false
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 200
          pattern: .*\S.*
        checkout_url:
          $ref: '#/components/schemas/HTTPSURL'
      required:
        - name
        - checkout_url
    SpendStatus:
      type: string
      enum:
        - pending_approval
        - approved
        - declined
        - claimed
        - expired
        - canceled
        - issuance_unknown
        - blocked
    ClaimWithinSeconds:
      type: integer
      minimum: 1
      maximum: 86400
      default: 300
      description: >-
        Seconds after approved_at within which the first claim must complete.
        Resolved and frozen at creation, shown during approval, and returned on
        the intent. Does not extend credential TTL. The supported range is 1-300
        seconds; a larger valid duration returns HTTP 422
        claim_window_unsupported before intent creation. Null and out-of-range
        values are invalid.
    SpendApproval:
      type: object
      additionalProperties: false
      properties:
        authority:
          type: string
          enum:
            - owner
            - platform
            - business
          description: >-
            Party whose human approval is required: owner for a direct Agent's
            own Account, platform for a delegated Agent's owner, business for
            the Account whose card is used.
        status:
          type: string
          enum:
            - pending
            - approved
            - declined
        over_limit:
          type: boolean
          description: >-
            True when this party must explicitly approve exceeding one of its
            own limits.
        decided_at:
          type: integer
          minimum: 0
          description: Unix epoch seconds.
          format: int64
          nullable: true
      required:
        - authority
        - status
        - over_limit
        - decided_at
      description: >-
        One required human approval. Platform decisions precede the business
        decision; the business decides last. Approver identity is shown only in
        authenticated Ionic owner routes.
    SpendLimitBreach:
      type: object
      additionalProperties: false
      properties:
        authority:
          type: string
          enum:
            - owner
            - platform
            - business
          description: >-
            Party whose human approval is required: owner for a direct Agent's
            own Account, platform for a delegated Agent's owner, business for
            the Account whose card is used.
        limit_id:
          type: string
          pattern: ^alm_[0-9A-Za-z]{14}$
        rule:
          type: object
          additionalProperties: false
          properties:
            type:
              type: string
              enum:
                - max_amount
                - window_amount
                - window_count
            window:
              type: string
              enum:
                - 1h
                - 24h
                - 7d
                - 30d
              nullable: true
          required:
            - type
            - window
        limit:
          type: integer
          minimum: 1
          maximum: 9007199254740991
          description: Minor units for amount rules; a count for window_count.
        usage:
          type: integer
          minimum: 0
          maximum: 9007199254740991
          description: >-
            Approved card access already counted in the window when the breach
            was evaluated. Not money spent.
        requested:
          type: integer
          minimum: 0
          maximum: 9007199254740991
        on_breach:
          type: string
          enum:
            - hold
            - block
          description: >-
            What the rule does when exceeded: hold asks for an explicit
            approval, block refuses the request (decision 0110).
      required:
        - authority
        - limit_id
        - rule
        - limit
        - usage
        - requested
        - on_breach
      description: >-
        A limit this request exceeds. Frozen when evaluated; the matching
        approval covers only this overage.
    HTTPSURL:
      type: string
      minLength: 10
      maxLength: 2048
      pattern: ^https://[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?(?:/[^\s?#]*)?$
      description: >-
        Absolute HTTPS URL; no userinfo, port, query, fragment or whitespace.
        Return destinations require registration where specified. Seller
        pre-registration is not required when the caller supplies allowed_hosts.
  responses:
    '400':
      description: >-
        The request is invalid, for example `invalid_request`, `invalid_cursor`,
        or a missing `Idempotency-Key`.
      headers:
        Cache-Control:
          description: Always no-store, including errors and claim retries.
          schema:
            type: string
            enum:
              - no-store
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/BoundaryError'
    '401':
      description: The API key is missing, invalid, expired, or revoked.
      headers:
        Cache-Control:
          description: Always no-store, including errors and claim retries.
          schema:
            type: string
            enum:
              - no-store
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/BoundaryError'
    '403':
      description: >-
        The key or agent doesn't have access, for example `action_not_enabled`,
        `ACCOUNT_ACCESS_DENIED`, or `setup_access_denied`.
      headers:
        Cache-Control:
          description: Always no-store, including errors and claim retries.
          schema:
            type: string
            enum:
              - no-store
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/BoundaryError'
    '404':
      description: The object doesn't exist, or the key can't see it.
      headers:
        Cache-Control:
          description: Always no-store, including errors and claim retries.
          schema:
            type: string
            enum:
              - no-store
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/BoundaryError'
    '422':
      description: >-
        The request can't be completed: `checkout_unsupported`,
        `approval_required`, `limit_exceeded`, `intent_not_claimable`,
        `intent_expired`, `checkout_configuration_unavailable`,
        `claim_window_unsupported`, `currency_not_allowed`, or
        `setup_session_expired`. See [Recover without creating another
        purchase](/guides/spend-platform-integration#recover-without-creating-another-purchase).
      headers:
        Cache-Control:
          description: Always no-store, including errors and claim retries.
          schema:
            type: string
            enum:
              - no-store
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/SpendError'
    '429':
      description: Too many requests. Wait for `Retry-After`.
      headers:
        Cache-Control:
          description: Always no-store, including errors and claim retries.
          schema:
            type: string
            enum:
              - no-store
        Retry-After:
          description: Seconds to wait before a safe retry.
          schema:
            type: integer
            minimum: 1
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/BoundaryError'
    '503':
      description: >-
        The service is temporarily unavailable and the request wasn't processed.
        Retry with the same `Idempotency-Key`.
      headers:
        Cache-Control:
          description: Always no-store, including errors and claim retries.
          schema:
            type: string
            enum:
              - no-store
        Retry-After:
          description: Seconds to wait before a safe retry.
          schema:
            type: integer
            minimum: 1
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/BoundaryError'
  securitySchemes:
    secretKey:
      type: http
      scheme: bearer
      description: >-
        Backend secret key for hosted setup; Agent secret key for card inventory
        and every spending-request operation. A delegated request also selects
        the authorized business through Ionic-Account. Machine keys cannot
        approve requests.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.