API REFERENCE
Claim Subscription
On this page
/api/subscriptions/claimAttach a subscription bought through Create Subscription Session (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.
Authentication
x-api-key in header
bearerAuth bearer
Request
curl --request POST \
--url 'https://api.recoupable.dev/api/subscriptions/claim' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"session_id": "cs_live_a1b2c3d4e5f6g7h8i9j0"
}'Try it
Fill in the fields, send the request from your browser, and read the live response. The curl below updates as you type.
Kept in this browser tab only and cleared when it closes.
curl --request POST \
--url 'https://recoup-api.vercel.app/api/subscriptions/claim' \
--header 'Content-Type: application/json' \
--data '{
"session_id": "cs_live_a1b2c3d4e5f6g7h8i9j0"
}'Request body required
The Checkout session to claim
application/json
session_idstringrequiredThe Stripe Checkout session id from the session_id query parameter on the success URL.
Responses
200Subscription attached to the authenticated account (or already was)+
application/json
statusstring · enumrequiredValues: "success"
subscription_idstringrequiredThe Stripe subscription now attached to the authenticated account.
planstring · enumrequiredThe plan the subscription is on, resolved from its Stripe price.
Values: "starter", "pro"
400Bad request - missing session_id, or the session has no subscription+
application/json
statusstring · enumrequiredValues: "error"
errorstringrequiredMachine-readable code (session_not_found, already_claimed, no_subscription) or a validation message.
401Unauthorized - invalid or missing authentication+
application/json
statusstring · enumrequiredValues: "error"
errorstringrequiredMachine-readable code (session_not_found, already_claimed, no_subscription) or a validation message.
404Unknown Checkout session+
application/json
statusstring · enumrequiredValues: "error"
errorstringrequiredMachine-readable code (session_not_found, already_claimed, no_subscription) or a validation message.
{
"status": "error",
"error": "session_not_found"
}409The subscription belongs to another account that has signed in+
application/json
statusstring · enumrequiredValues: "error"
errorstringrequiredMachine-readable code (session_not_found, already_claimed, no_subscription) or a validation message.
{
"status": "error",
"error": "already_claimed"
}500Internal server error+
application/json
statusstring · enumrequiredValues: "error"
errorstringrequiredMachine-readable code (session_not_found, already_claimed, no_subscription) or a validation message.
Full specification
Download the OpenAPI file for complete schemas, constraints, and examples.
Download accounts.jsonView operation source
{
"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"
}
}
}
}
}
}