---
title: "Authorize a payment session"
---

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

# Authorize a payment session

Path: EdgeCart API › Storefront

`POST /store/payment-sessions/{id}/authorize`

URL: `https://{store_domain}/api/store/payment-sessions/{id}/authorize`

Authorizes the session with its provider and returns the payment collection.

## Authentication

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

## Path parameters

- `id` (`authorizeStorefrontPaymentSession.path.id`; string, required)

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://your-store.example.com/api/store/payment-sessions/<id>/authorize' \
  --header 'x-publishable-api-key: <x-publishable-api-key>'
```

### TypeScript

```typescript
const url = 'https://your-store.example.com/api/store/payment-sessions/<id>/authorize';
const options = {
  method: 'POST',
  headers: {'x-publishable-api-key': '<x-publishable-api-key>'}
};

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-sessions/<id>/authorize"

headers = {"x-publishable-api-key": "<x-publishable-api-key>"}

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

print(response.text)
```

## Responses

### 200

The payment collection after authorization.

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

### 400

The session cannot be authorized.

#### Example

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

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


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