---
title: "Create a payment collection"
---

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

# Create a payment collection

Path: EdgeCart API › Storefront

`POST /store/payment-collections`

URL: `https://{store_domain}/api/store/payment-collections`

Creates a payment collection for a cart or an existing order.

## Authentication

- `publishableKey`, apiKey, in header, header `x-publishable-api-key`

## Request body

_Required._

- `cart_id` (`createStorefrontPaymentCollection.cart_id`; string, optional)
- `order_id` (`createStorefrontPaymentCollection.order_id`; string, optional)
- `metadata` (`createStorefrontPaymentCollection.metadata`; object, optional)

## Example request

```json
{
  "cart_id": "string",
  "order_id": "string",
  "metadata": {}
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url https://your-store.example.com/api/store/payment-collections \
  --header 'Content-Type: application/json' \
  --header 'x-publishable-api-key: <x-publishable-api-key>' \
  --data '
{
  "cart_id": "string",
  "order_id": "string",
  "metadata": {}
}
'
```

### TypeScript

```typescript
const url = 'https://your-store.example.com/api/store/payment-collections';
const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-publishable-api-key': '<x-publishable-api-key>'
  },
  body: JSON.stringify({cart_id: 'string', order_id: 'string', metadata: {}})
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://your-store.example.com/api/store/payment-collections"

payload = {
    "cart_id": "string",
    "order_id": "string",
    "metadata": {}
}
headers = {
    "Content-Type": "application/json",
    "x-publishable-api-key": "<x-publishable-api-key>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 201

The created payment collection.

#### Example

```json
{
  "payment_collection": {
    "id": "string",
    "cart_id": "string",
    "order_id": "string",
    "currency_code": "string",
    "amount": 0,
    "authorized_amount": 0,
    "captured_amount": 0,
    "refunded_amount": 0,
    "completed_at": "2019-08-24T14:15:22Z",
    "status": "not_paid",
    "metadata": {},
    "sessions": [
      {
        "id": "string",
        "payment_collection_id": "string",
        "currency_code": "string",
        "amount": 0,
        "provider_id": "string",
        "data": {},
        "context": {},
        "status": "pending",
        "authorized_at": "2019-08-24T14:15:22Z",
        "metadata": {},
        "created_at": "2019-08-24T14:15:22Z",
        "updated_at": "2019-08-24T14:15:22Z"
      }
    ],
    "payments": [
      {
        "id": "string",
        "payment_collection_id": "string",
        "payment_session_id": "string",
        "amount": 0,
        "currency_code": "string",
        "provider_id": "string",
        "data": {},
        "metadata": {},
        "captured_at": "2019-08-24T14:15:22Z",
        "canceled_at": "2019-08-24T14:15:22Z",
        "captures": [
          {
            "id": "string",
            "payment_id": "string",
            "amount": 0,
            "reference": "string",
            "idempotency_key": "string",
            "metadata": {},
            "created_at": "2019-08-24T14:15:22Z"
          }
        ],
        "refunds": [
          {
            "id": "string",
            "payment_id": "string",
            "amount": 0,
            "reference": "string",
            "idempotency_key": "string",
            "status": "pending",
            "error": "string",
            "metadata": {},
            "created_at": "2019-08-24T14:15:22Z"
          }
        ],
        "created_at": "2019-08-24T14:15:22Z",
        "updated_at": "2019-08-24T14:15:22Z"
      }
    ],
    "created_at": "2019-08-24T14:15:22Z",
    "updated_at": "2019-08-24T14:15:22Z"
  }
}
```

- `payment_collection` (`createStorefrontPaymentCollection.response.201.payment_collection`; object, required)
  - `id` (`createStorefrontPaymentCollection.response.201.payment_collection.id`; string, required)
  - `amount` (`createStorefrontPaymentCollection.response.201.payment_collection.amount`; integer, required)
  - `status` (`createStorefrontPaymentCollection.response.201.payment_collection.status`; string, required)
    - one of `"not_paid"`, `"awaiting"`, `"authorized"`, `"partially_authorized"`, `"canceled"`, `"failed"`, `"partially_captured"`, `"completed"`
  - `sessions` (`createStorefrontPaymentCollection.response.201.payment_collection.sessions`; array of object, required)
    - `id` (`createStorefrontPaymentCollection.response.201.payment_collection.sessions.id`; string, required)
    - `payment_collection_id` (`createStorefrontPaymentCollection.response.201.payment_collection.sessions.payment_collection_id`; string, required)
    - `amount` (`createStorefrontPaymentCollection.response.201.payment_collection.sessions.amount`; integer, required)
    - `provider_id` (`createStorefrontPaymentCollection.response.201.payment_collection.sessions.provider_id`; string, required)
    - `status` (`createStorefrontPaymentCollection.response.201.payment_collection.sessions.status`; string, required)
      - one of `"pending"`, `"requires_more"`, `"authorized"`, `"error"`, `"canceled"`, `"pending_authorization"`
    - `currency_code` (`createStorefrontPaymentCollection.response.201.payment_collection.sessions.currency_code`; string, optional)
    - `data` (`createStorefrontPaymentCollection.response.201.payment_collection.sessions.data`; object, optional)
    - `context` (`createStorefrontPaymentCollection.response.201.payment_collection.sessions.context`; object, optional)
    - `authorized_at` (`createStorefrontPaymentCollection.response.201.payment_collection.sessions.authorized_at`; string | null, optional)
      - format: `date-time`
    - `metadata` (`createStorefrontPaymentCollection.response.201.payment_collection.sessions.metadata`; object, optional)
    - `created_at` (`createStorefrontPaymentCollection.response.201.payment_collection.sessions.created_at`; string, optional)
      - format: `date-time`
    - `updated_at` (`createStorefrontPaymentCollection.response.201.payment_collection.sessions.updated_at`; string, optional)
      - format: `date-time`
  - `payments` (`createStorefrontPaymentCollection.response.201.payment_collection.payments`; array of object, required)
    - `id` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.id`; string, required)
    - `payment_collection_id` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.payment_collection_id`; string, required)
    - `amount` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.amount`; integer, required)
    - `provider_id` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.provider_id`; string, required)
    - `payment_session_id` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.payment_session_id`; string | null, optional)
    - `currency_code` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.currency_code`; string, optional)
    - `data` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.data`; object, optional)
    - `metadata` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.metadata`; object, optional)
    - `captured_at` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.captured_at`; string | null, optional)
      - format: `date-time`
    - `canceled_at` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.canceled_at`; string | null, optional)
      - format: `date-time`
    - `captures` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.captures`; array of object, optional)
      - `id` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.captures.id`; string, required)
      - `payment_id` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.captures.payment_id`; string, required)
      - `amount` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.captures.amount`; integer, required)
      - `reference` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.captures.reference`; string | null, optional)
      - `idempotency_key` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.captures.idempotency_key`; string | null, optional)
      - `metadata` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.captures.metadata`; object, optional)
      - `created_at` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.captures.created_at`; string, optional)
        - format: `date-time`
    - `refunds` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.refunds`; array of object, optional)
      - `id` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.refunds.id`; string, required)
      - `payment_id` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.refunds.payment_id`; string, required)
      - `amount` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.refunds.amount`; integer, required)
      - `status` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.refunds.status`; string, required)
        - one of `"pending"`, `"succeeded"`, `"failed"`, `"canceled"`
      - `reference` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.refunds.reference`; string | null, optional)
      - `idempotency_key` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.refunds.idempotency_key`; string | null, optional)
      - `error` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.refunds.error`; string | null, optional)
      - `metadata` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.refunds.metadata`; object, optional)
      - `created_at` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.refunds.created_at`; string, optional)
        - format: `date-time`
    - `created_at` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.created_at`; string, optional)
      - format: `date-time`
    - `updated_at` (`createStorefrontPaymentCollection.response.201.payment_collection.payments.updated_at`; string, optional)
      - format: `date-time`
  - `cart_id` (`createStorefrontPaymentCollection.response.201.payment_collection.cart_id`; string | null, optional)
  - `order_id` (`createStorefrontPaymentCollection.response.201.payment_collection.order_id`; string | null, optional)
  - `currency_code` (`createStorefrontPaymentCollection.response.201.payment_collection.currency_code`; string, optional)
  - `authorized_amount` (`createStorefrontPaymentCollection.response.201.payment_collection.authorized_amount`; integer, optional)
  - `captured_amount` (`createStorefrontPaymentCollection.response.201.payment_collection.captured_amount`; integer, optional)
  - `refunded_amount` (`createStorefrontPaymentCollection.response.201.payment_collection.refunded_amount`; integer, optional)
  - `completed_at` (`createStorefrontPaymentCollection.response.201.payment_collection.completed_at`; string | null, optional)
    - format: `date-time`
  - `metadata` (`createStorefrontPaymentCollection.response.201.payment_collection.metadata`; object, optional)
  - `created_at` (`createStorefrontPaymentCollection.response.201.payment_collection.created_at`; string, optional)
    - format: `date-time`
  - `updated_at` (`createStorefrontPaymentCollection.response.201.payment_collection.updated_at`; string, optional)
    - format: `date-time`

### 400

The payment collection input is invalid.

#### Example

```json
{
  "type": "not_found",
  "message": "No active store is available for this deployment",
  "code": "store_not_configured"
}
```

- `type` (`createStorefrontPaymentCollection.response.400.type`; string, required)
- `message` (`createStorefrontPaymentCollection.response.400.message`; string, required)
- `code` (`createStorefrontPaymentCollection.response.400.code`; string, optional)


Source: https://edgecart.dev/api/store/payment-collections/index.md
