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

# Claim an unassigned store purchase into an org

> Claims one of the caller's unassigned store purchases into an org, completing a purchase intent for it and granting it once from its current state.

Use this tool when you need to:
- Recover a paid store purchase that reached no org
- Credit a purchase listed by listBillingUnassignedStorePurchases to the org of the caller's choice

Examples:
- POST /billing/store/unassigned-purchases/{transactionID}/claim {"org_id": "6f1c2a9e-3b7d-4c55-9a2e-0d8b1f4e7c21"}
- POST /billing/store/unassigned-purchases/2000000123456789/claim {"org_id": "6f1c2a9e-3b7d-4c55-9a2e-0d8b1f4e7c21"}

Hints:
- transactionID is the purchase's transaction_id, 1 to 128 letters, digits or . _ : - characters; org_id is required, the uuid of the org to claim it into. The schema answers 422 for either out of shape.
- Recovery of a paid purchase, not the start of one: the org's payment state is not consulted. The caller's own open intent for the same product in the org is the one completed; without one, a new intent is written already bound and completed.
- Grants once from the purchase's current state: a refunded period grants nothing (its refund is recorded), but when a subscription's renewal was refunded ahead of its period, the paid period it follows is still opened. Answers 200 with the StorePurchaseClaim: transaction_id, org_id, state and the completed checkout_session.
- Claiming a purchase already claimed returns that claim unchanged, whatever org_id says, to a caller still an owner, admin or billing member of the org it went into.
- Use bindBillingCheckoutSessionTransaction instead when the device still holds the purchase intent it bought under.
- Any signed-in user, for purchases made with their own store identity, into an org where they are an owner, admin or billing member; anyone else, a non-member included, is refused with 403 requires_org_admin, and an agent host's grant with 403 agent_host_route_not_allowed.
- Refused with 404 for a purchase not found or not the caller's, and 409 when the purchase cannot be fulfilled in the org: a sandbox purchase outside the allowlist, a subscription for an org that already holds another, or a subscription whose paid period ended with no renewal or expiration reported yet.



## OpenAPI

````yaml api-reference/openapi.json POST /billing/store/unassigned-purchases/{transactionID}/claim
openapi: 3.1.0
info:
  title: Aether API
  version: 0.1.0
servers:
  - url: https://api.runaether.dev
security:
  - bearerAuth: []
paths:
  /billing/store/unassigned-purchases/{transactionID}/claim:
    post:
      tags:
        - billing
      summary: Claim an unassigned store purchase into an org
      description: >-
        Claims one of the caller's unassigned store purchases into an org,
        completing a purchase intent for it and granting it once from its
        current state.


        Use this tool when you need to:

        - Recover a paid store purchase that reached no org

        - Credit a purchase listed by listBillingUnassignedStorePurchases to the
        org of the caller's choice


        Examples:

        - POST /billing/store/unassigned-purchases/{transactionID}/claim
        {"org_id": "6f1c2a9e-3b7d-4c55-9a2e-0d8b1f4e7c21"}

        - POST /billing/store/unassigned-purchases/2000000123456789/claim
        {"org_id": "6f1c2a9e-3b7d-4c55-9a2e-0d8b1f4e7c21"}


        Hints:

        - transactionID is the purchase's transaction_id, 1 to 128 letters,
        digits or . _ : - characters; org_id is required, the uuid of the org to
        claim it into. The schema answers 422 for either out of shape.

        - Recovery of a paid purchase, not the start of one: the org's payment
        state is not consulted. The caller's own open intent for the same
        product in the org is the one completed; without one, a new intent is
        written already bound and completed.

        - Grants once from the purchase's current state: a refunded period
        grants nothing (its refund is recorded), but when a subscription's
        renewal was refunded ahead of its period, the paid period it follows is
        still opened. Answers 200 with the StorePurchaseClaim: transaction_id,
        org_id, state and the completed checkout_session.

        - Claiming a purchase already claimed returns that claim unchanged,
        whatever org_id says, to a caller still an owner, admin or billing
        member of the org it went into.

        - Use bindBillingCheckoutSessionTransaction instead when the device
        still holds the purchase intent it bought under.

        - Any signed-in user, for purchases made with their own store identity,
        into an org where they are an owner, admin or billing member; anyone
        else, a non-member included, is refused with 403 requires_org_admin, and
        an agent host's grant with 403 agent_host_route_not_allowed.

        - Refused with 404 for a purchase not found or not the caller's, and 409
        when the purchase cannot be fulfilled in the org: a sandbox purchase
        outside the allowlist, a subscription for an org that already holds
        another, or a subscription whose paid period ended with no renewal or
        expiration reported yet.
      operationId: claimBillingUnassignedStorePurchase
      parameters:
        - in: path
          name: transactionID
          required: true
          schema:
            pattern: ^[A-Za-z0-9._:-]{1,128}$
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ClaimStorePurchaseRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StorePurchaseClaim'
          description: OK
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingErrorResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/BillingErrorResponse'
                  - $ref: '#/components/schemas/OrgAuthorizationErrorResponse'
          description: Forbidden
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingErrorResponse'
          description: Not Found
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingErrorResponse'
          description: Conflict
        '410':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingErrorResponse'
          description: Gone
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingErrorResponse'
          description: Unprocessable Entity
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingErrorResponse'
          description: Internal Server Error
components:
  schemas:
    ClaimStorePurchaseRequest:
      additionalProperties: false
      properties:
        org_id:
          description: The org to claim the purchase into; the caller must administer it.
          format: uuid
          type: string
      required:
        - org_id
      type: object
    StorePurchaseClaim:
      additionalProperties: false
      properties:
        checkout_session:
          $ref: '#/components/schemas/BillingCheckoutSession'
        org_id:
          format: uuid
          type: string
        state:
          enum:
            - paid
            - refunded
            - expired
          type: string
        transaction_id:
          type: string
      required:
        - transaction_id
        - org_id
        - state
        - checkout_session
      type: object
    BillingErrorResponse:
      additionalProperties: false
      properties:
        code:
          enum:
            - bad_gateway
            - bad_request
            - checkout_pending
            - cli_upgrade_required
            - client_outdated
            - conflict
            - enterprise_invoice
            - forbidden
            - free_tier
            - gateway_timeout
            - gone
            - internal_error
            - invalid_surface
            - managed_elsewhere
            - method_not_allowed
            - no_billing_history
            - not_acceptable
            - not_found
            - not_implemented
            - payment_delinquent
            - payment_required
            - personal_org_requires_personal_plan
            - precondition_failed
            - provider_unavailable
            - rate_limited
            - request_canceled
            - request_timeout
            - request_too_large
            - requires_org_admin
            - service_unavailable
            - subscription_active
            - subscription_pending
            - team_org_requires_team_plan
            - team_plan_web_only
            - team_seats_via_membership
            - unauthenticated
            - unsupported_media_type
            - validation_failed
            - warm_slot_occupied
            - web_only
          minLength: 1
          type: string
        error:
          minLength: 1
          type: string
        errors:
          items:
            $ref: '#/components/schemas/ErrorDetail'
          type: array
      required:
        - error
        - code
      type: object
    OrgAuthorizationErrorResponse:
      additionalProperties: false
      properties:
        code:
          enum:
            - org_membership_required
            - org_role_insufficient
            - org_suspended
            - account_deleting
            - agent_host_route_not_allowed
            - credential_kind_not_admitted
            - grant_scope_insufficient
          type: string
        error:
          minLength: 1
          type: string
      required:
        - error
        - code
      type: object
    BillingCheckoutSession:
      discriminator:
        mapping:
          credit_pack: '#/components/schemas/BillingCreditPackCheckoutSession'
          inference_topup: '#/components/schemas/BillingInferenceTopUpCheckoutSession'
          subscription: '#/components/schemas/BillingSubscriptionCheckoutSession'
        propertyName: checkout_type
      oneOf:
        - $ref: '#/components/schemas/BillingSubscriptionCheckoutSession'
        - $ref: '#/components/schemas/BillingCreditPackCheckoutSession'
        - $ref: '#/components/schemas/BillingInferenceTopUpCheckoutSession'
    ErrorDetail:
      additionalProperties: false
      properties:
        location:
          description: >-
            Where the error occurred, e.g. 'body.items[3].tags' or
            'path.thing-id'
          type: string
        message:
          description: Error message text
          type: string
        value:
          description: The value at the given location
      type: object
    BillingCreditPackCheckoutSession:
      additionalProperties: false
      properties:
        amount_usd:
          format: double
          type: number
        checkout_session_id:
          format: uuid
          type: string
        checkout_session_token:
          pattern: ^pcs_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
          type: string
        checkout_type:
          enum:
            - credit_pack
          type: string
        claimed_store_purchase:
          description: >-
            Present and true when binding the store transaction claimed the
            purchase the store had already reported: the intent completed and
            granted from it.
          type: boolean
        credit_pack_id:
          enum:
            - credits_100
            - credits_250
            - credits_500
            - credits_1000
          type: string
        credits:
          format: int64
          type: integer
        purchase_status:
          enum:
            - failed
            - granted
            - pending
            - pending_grant
          type: string
        status:
          enum:
            - created
            - completed
            - expired
            - failed
          type: string
        store_app_user_id:
          description: >-
            The store identity the device buys as. Present only when a store
            purchase intent is created.
          format: uuid
          type: string
        store_product_id:
          description: >-
            The store product the device buys. Present only when a store
            purchase intent is created.
          type: string
        url:
          description: >-
            The Stripe hosted checkout to open. Absent for a store purchase
            intent.
          type: string
      required:
        - checkout_session_id
        - checkout_session_token
        - checkout_type
        - status
        - purchase_status
        - credit_pack_id
        - credits
        - amount_usd
      type: object
    BillingInferenceTopUpCheckoutSession:
      additionalProperties: false
      properties:
        amount_usd:
          format: double
          type: number
        checkout_session_id:
          format: uuid
          type: string
        checkout_session_token:
          pattern: ^pcs_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
          type: string
        checkout_type:
          enum:
            - inference_topup
          type: string
        claimed_store_purchase:
          description: >-
            Present and true when binding the store transaction claimed the
            purchase the store had already reported: the intent completed and
            granted from it.
          type: boolean
        fee_usd:
          format: double
          type: number
        purchase_status:
          enum:
            - failed
            - granted
            - pending
            - pending_grant
          type: string
        status:
          enum:
            - created
            - completed
            - expired
            - failed
          type: string
        store_app_user_id:
          description: >-
            The store identity the device buys as. Present only when a store
            purchase intent is created.
          format: uuid
          type: string
        store_product_id:
          description: >-
            The store product the device buys. Present only when a store
            purchase intent is created.
          type: string
        url:
          description: >-
            The Stripe hosted checkout to open. Absent for a store purchase
            intent.
          type: string
      required:
        - checkout_session_id
        - checkout_session_token
        - checkout_type
        - status
        - purchase_status
        - amount_usd
        - fee_usd
      type: object
    BillingSubscriptionCheckoutSession:
      additionalProperties: false
      properties:
        checkout_session_id:
          format: uuid
          type: string
        checkout_session_token:
          pattern: ^pcs_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
          type: string
        checkout_type:
          enum:
            - subscription
          type: string
        claimed_store_purchase:
          description: >-
            Present and true when binding the store transaction claimed the
            purchase the store had already reported: the intent completed and
            granted from it.
          type: boolean
        status:
          enum:
            - created
            - completed
            - expired
            - failed
          type: string
        store_app_user_id:
          description: >-
            The store identity the device buys as. Present only when a store
            purchase intent is created.
          format: uuid
          type: string
        store_product_id:
          description: >-
            The store product the device buys. Present only when a store
            purchase intent is created.
          type: string
        subscription_status:
          enum:
            - active
            - failed
            - pending
            - pending_webhook
          type: string
        target_tier:
          enum:
            - starter
            - pro
            - max
            - team
          type: string
        url:
          description: >-
            The Stripe hosted checkout to open. Absent for a store purchase
            intent.
          type: string
      required:
        - checkout_session_id
        - checkout_session_token
        - checkout_type
        - status
        - target_tier
        - subscription_status
      type: object
  securitySchemes:
    bearerAuth:
      bearerFormat: JWT
      scheme: bearer
      type: http

````

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