# Get a purchase

`GET https://api.coach-platform.com/api/public/purchases/{purchaseId}`

Get a customer purchase by id.

- Resource: Purchases
- Authentication: API key in the `Authorization: Bearer cp_live_...` header
- HTML version: https://www.coach-platform.com/docs/api/reference/get-purchases-purchase-id
- OpenAPI spec: https://www.coach-platform.com/openapi.json

## Path parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `purchaseId` | string | Yes |   |

## Responses

| Status | Description |
|---|---|
| `200` OK | Successful response |
| `400` Bad Request |  |
| `401` Unauthorized |  |
| `403` Forbidden |  |
| `404` Not Found |  |
| `409` Conflict |  |
| `429` Too Many Requests |  |
| `500` Internal Server Error |  |

### 200 OK

Content type: `application/json`

| Field | Type | Description |
|---|---|---|
| `data` | object |   |
| `data.id` | string |   |
| `data.coachId` | string |   |
| `data.traineeId` | string |   |
| `data.productId` | string |   |
| `data.purchaseDate` | string<date-time> |   |
| `data.expirationDate` | string<date-time> |   |
| `data.purchaseAmount` | number |   |
| `data.currency` | string | Allowed values: `ILS`, `USD`, `EUR`, `GBP`. |
| `data.status` | string | Allowed values: `ACTIVE`, `EXPIRED`, `CANCELLED`, `PENDING`, `WAITING_FOR_PAYMENT`. |
| `data.initialCredits` | number |   |
| `data.remainingCredits` | number |   |
| `data.membershipStartDate` | string<date-time> |   |
| `data.membershipEndDate` | string<date-time> |   |
| `data.currentPeriodUsages` | number |   |
| `data.periodResetDate` | string<date-time> |   |
| `data.createdAt` | string<date-time> |   |
| `data.updatedAt` | string<date-time> |   |

Example:

```json
{
  "data": {
    "id": "<string>",
    "coachId": "<string>",
    "traineeId": "<string>",
    "productId": "<string>",
    "purchaseDate": "<date-time>",
    "expirationDate": "<date-time>",
    "purchaseAmount": 123,
    "currency": "ILS",
    "status": "ACTIVE",
    "initialCredits": 123,
    "remainingCredits": 123,
    "membershipStartDate": "<date-time>",
    "membershipEndDate": "<date-time>",
    "currentPeriodUsages": 123,
    "periodResetDate": "<date-time>",
    "createdAt": "<date-time>",
    "updatedAt": "<date-time>"
  }
}
```

### Error responses 400, 401, 403, 404, 409, 429, 500

Content type: `application/json`

| Field | Type | Description |
|---|---|---|
| `error` | object |   |
| `error.code` | string |   |
| `error.message` | string |   |
| `error.fix` | string \| null |   |
| `error.details` | object \| null |   |
| `error.retryAfterMs` | number \| null |   |

Example:

```json
{
  "error": {
    "code": "<string>",
    "message": "<string>",
    "fix": "<string>",
    "details": {},
    "retryAfterMs": 123
  }
}
```

## Examples

### cURL

```bash
curl --request GET \
  --url 'https://api.coach-platform.com/api/public/purchases/<purchaseId>' \
  --header 'Authorization: Bearer cp_live_...'
```

### JavaScript (fetch)

```js
const response = await fetch('https://api.coach-platform.com/api/public/purchases/<purchaseId>', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer cp_live_...',
  },
});

const data = await response.json();
```

## Related endpoints

- [List purchases](https://www.coach-platform.com/docs/api/reference/get-purchases/index.md): `GET /api/public/purchases`. List customer purchases.
- [Record a purchase](https://www.coach-platform.com/docs/api/reference/post-purchases/index.md): `POST /api/public/purchases`. Record a product purchase for a trainee.
- Previous: [Record a purchase](https://www.coach-platform.com/docs/api/reference/post-purchases/index.md): `POST /api/public/purchases`. Record a product purchase for a trainee.
- Next: [List webhook subscriptions](https://www.coach-platform.com/docs/api/reference/get-webhooks/index.md): `GET /api/public/webhooks`. List webhook subscriptions for the current key's coach
