# Read a finished checkout back

> Page: https://docs.plotwork.dev/api/post-user-billing-verify-checkout. Index of every page: https://docs.plotwork.dev/llms.txt

Asks Stripe for the checkout session and its subscription and stores the same state the webhook stores.

`POST /user/billing/verify-checkout`

## TL;DR

| Question | Answer |
|---|---|
| What does it do? | Read a finished checkout back. |
| What does it take? | A JSON body of type [`VerifyCheckoutBody`](https://docs.plotwork.dev/api/schemas.md#verifycheckoutbody). |
| What does it return? | Status 200 with a body of type [`BillingState`](https://docs.plotwork.dev/api/schemas.md#billingstate). |
| What can go wrong? | `400` the body is not valid; `401` not signed in; `403` the request came from an origin that may not make changes; `404` no such checkout session for this account; `429` too many requests; `502` stripe could not complete the request; `503` billing is not set up on this server. Every failure uses the one error envelope. |

## What it does

Asks Stripe for the checkout session and its subscription and stores the same state the webhook stores. A session that is not this account's, or does not exist, is a 404 either way.

## Request body

The body has the type [`VerifyCheckoutBody`](https://docs.plotwork.dev/api/schemas.md#verifycheckoutbody).

| Field | Type | Required | Description |
|---|---|---|---|
| `sessionId` | `string` | yes | The Checkout Session id Stripe put in the return address. pattern `^cs_[A-Za-z0-9_]{8,200}$`. |

## Responses

| Status | Meaning | Body |
|---|---|---|
| 200 | The account's plan after the check. | [`BillingState`](https://docs.plotwork.dev/api/schemas.md#billingstate) |
| 400 | The body is not valid. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 401 | Not signed in. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 403 | The request came from an origin that may not make changes. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 404 | No such checkout session for this account. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 429 | Too many requests. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 502 | Stripe could not complete the request. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |
| 503 | Billing is not set up on this server. | [`ErrorResponse`](https://docs.plotwork.dev/api/schemas.md#errorresponse) |

## Response body

A 200 answer has the type [`BillingState`](https://docs.plotwork.dev/api/schemas.md#billingstate).

| Field | Type | Required | Description |
|---|---|---|---|
| `plan` | `"free" \| "pro"` | yes | The plan the account gets right now. It is the free plan whenever the subscription is not paying, whatever plan was bought. |
| `status` | `string` | yes | Stripe's status for the subscription (`active`, `trialing`, `past_due`, `canceled`, `unpaid`, `incomplete`, and so on), or `none` when the account never started one. |
| `currentPeriodEnd` | `integer \| null` | yes | When the period paid for ends, in milliseconds since the epoch, or null when there is no subscription. |
| `cancelAtPeriodEnd` | `boolean` | yes | True while the subscription is scheduled to end at the close of the period already paid for. |
| `hasCustomer` | `boolean` | yes | True once the account has billing details at Stripe, which is when the billing portal can be opened. |

## See also

| Doc | Why |
|---|---|
| [API reference](https://docs.plotwork.dev/api/reference.md) | Every endpoint, and the error envelope |
| [Schemas](https://docs.plotwork.dev/api/schemas.md) | Every request and response type |
| [Tool reference](https://docs.plotwork.dev/mcp/tools.md) | The operations as callable tools |
