# Claim Subscription

Source: https://recoupable.dev/docs/api-reference/subscriptions/claim-create

Attach a subscription bought through [Create Subscription Session](/api-reference/subscriptions/sessions-create) (anonymous path) to the authenticated account. Needed only when the signed-in email differs from the email typed into Stripe Checkout; when they match, the webhook already linked the subscription and this call is a no-op that returns 200.

## POST /api/subscriptions/claim

Full OpenAPI specification: https://recoupable.dev/docs/spec/accounts.json

## Authentication

This operation requires one of the security alternatives in the specification below. Security scheme definitions are included where present in the published specification.

[Authentication guide](https://recoupable.dev/docs/authentication)

## Operation and referenced schemas

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Recoup API - Accounts",
    "description": "API documentation for the Recoup platform - an AI agent platform for the music industry",
    "license": {
      "name": "MIT"
    },
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.recoupable.dev"
    }
  ],
  "paths": {
    "/api/subscriptions/claim": {
      "post": {
        "description": "Attach a subscription bought through [Create Subscription Session](/api-reference/subscriptions/sessions-create) (anonymous path) to the authenticated account. Needed only when the signed-in email differs from the email typed into Stripe Checkout; when they match, the webhook already linked the subscription and this call is a no-op that returns 200.",
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "description": "The Checkout session to claim",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClaimSubscriptionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Subscription attached to the authenticated account (or already was)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClaimSubscriptionResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request - missing `session_id`, or the session has no subscription",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClaimSubscriptionErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - invalid or missing authentication",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClaimSubscriptionErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Unknown Checkout session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClaimSubscriptionErrorResponse"
                },
                "example": {
                  "status": "error",
                  "error": "session_not_found"
                }
              }
            }
          },
          "409": {
            "description": "The subscription belongs to another account that has signed in",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClaimSubscriptionErrorResponse"
                },
                "example": {
                  "status": "error",
                  "error": "already_claimed"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClaimSubscriptionErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ClaimSubscriptionRequest": {
        "type": "object",
        "required": [
          "session_id"
        ],
        "properties": {
          "session_id": {
            "type": "string",
            "description": "The Stripe Checkout session id from the `session_id` query parameter on the success URL.",
            "example": "cs_live_a1b2c3d4e5f6g7h8i9j0"
          }
        }
      },
      "ClaimSubscriptionResponse": {
        "type": "object",
        "required": [
          "status",
          "subscription_id",
          "plan"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "success"
            ]
          },
          "subscription_id": {
            "type": "string",
            "description": "The Stripe subscription now attached to the authenticated account.",
            "example": "sub_1Rz0abc123"
          },
          "plan": {
            "type": "string",
            "enum": [
              "starter",
              "pro"
            ],
            "description": "The plan the subscription is on, resolved from its Stripe price.",
            "example": "pro"
          }
        }
      },
      "ClaimSubscriptionErrorResponse": {
        "type": "object",
        "required": [
          "status",
          "error"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "error"
            ]
          },
          "error": {
            "type": "string",
            "description": "Machine-readable code (`session_not_found`, `already_claimed`, `no_subscription`) or a validation message.",
            "example": "already_claimed"
          }
        }
      }
    },
    "securitySchemes": {
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Your Recoup API key. [Learn more](/quickstart#api-keys)."
      },
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  }
}
```
