---
# @generated by sylphx-gen. Do not edit.
title: "Batch expire on a checkout session"
description: "`money.checkout_sessions.batch_expire` (POST /v1/{parent}/checkout_sessions:batchExpire): Expires open checkouts and materialized recoveries of one subject and scope."
type: reference
product: payments
summary: "Expires open checkouts and materialized recoveries of one subject and scope."
nav: false
---

Expires open checkouts and materialized recoveries of one subject and scope.

- **Path** `POST https://api.sylphx.com/v1/orgs/acme/projects/shop/envs/production/checkout_sessions:batchExpire`
- **Scope** `billing:write`
- **Effect** `write` — a successful call changes state.
- **Collection** [checkout_sessions](/docs/api/checkout_sessions)

## Request

| Field | Type | What it is |
| --- | --- | --- |
| `parent` | `string` | The environment whose sessions are eligible to expire. Required. |
| `scope` | `CheckoutSessionScope` | The exact subject and immutable metadata selector; never customer-wide. Required. |

### CheckoutSessionScope

| Field | Type | What it is |
| --- | --- | --- |
| `subject` | `Subject` | The payer subject recorded by Money, not a mutable processor customer field. Required. |
| `metadata_key` | `string` | Exact key in the checkout's immutable Money metadata, e.g. workspace_id. Required. |
| `metadata_value` | `string` | Exact non-empty metadata value. Required. |

### Subject

| Field | Type | What it is |
| --- | --- | --- |
| `end_user` | `string` | An end user's id (Sylphx Auth, or the app's own OIDC issuer). One of the `kind` group. |
| `customer_organization` | `string` | A customer organization's id. One of the `kind` group. |

## Response

| Field | Type | What it is |
| --- | --- | --- |
| `expired_checkout_sessions` | `string[]` | Money resource names independently confirmed expired. Output only. |
| `expired_recovered_session_ids` | `string[]` | Materialized Stripe recovery sessions independently confirmed expired. Output only. |
| `recovery_not_revoked_checkout_sessions` | `string[]` | Original Money resources whose Stripe recovery was enabled or could not be proven disabled. Stripe-issued recovery URLs are NOT revoked by this call. Output only. |
| `completed_checkout_sessions` | `string[]` | Checkouts that completed before expiry; their payments must still settle. Output only. |

## Errors

- [`UNAUTHENTICATED`](/docs/api/errors/UNAUTHENTICATED) — No valid key or token was presented.
- [`PERMISSION_DENIED`](/docs/api/errors/PERMISSION_DENIED) — The key lacks the method's permission.
- [`INVALID_FIELD`](/docs/api/errors/INVALID_FIELD) — A field failed validation.
- [`INVALID_STATE`](/docs/api/errors/INVALID_STATE) — The Resource is in a state that forbids the call.
- [`UNAVAILABLE`](/docs/api/errors/UNAVAILABLE) — The Resource store, the owning service's backend, or the key verifier's snapshot is unavailable; retry after Retry-After.

Every error arrives in the body [Errors](/docs/platform/errors) describes.

## Examples

**cURL**

```curl
curl -X POST "https://api.sylphx.com/v1/orgs/acme/projects/shop/envs/production/checkout_sessions:batchExpire" \
  -H "Authorization: Bearer $SYLPHX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"scope":{"metadata_key":"…","metadata_value":"…","subject":{}}}'
```

**TypeScript**

```ts
const response = await sylphx.money.checkoutSessions.batchExpire({ parent: 'orgs/acme/projects/shop/envs/production', scope: { metadataKey: '…', metadataValue: '…', subject: {} } })
```

**Rust**

```rust
let mut req = sylphx::money::BatchExpireCheckoutSessionsRequest::default();
req.parent = "orgs/acme/projects/shop/envs/production".to_string();
req.scope = Some(sylphx::money::CheckoutSessionScope {
    metadata_key: "…".to_string(),
    metadata_value: "…".to_string(),
    subject: Some(Default::default()),
    ..Default::default()
});
let response = sx.money().checkout_sessions().batch_expire(req).await?;
```

**CLI**

```bash
sylphx money checkout-sessions batch-expire orgs/acme/projects/shop/envs/production
```

**MCP**

```json
{ "method_id": "money.checkout_sessions.batch_expire", "args": {"parent":"orgs/acme/projects/shop/envs/production","scope":{"metadata_key":"…","metadata_value":"…","subject":{}}} }
```
