# List purchase transactions

URL: https://docs.sparklayer.io/developers/api/purchasing/get-purchase-transactions
Operation: `GET /api/v1/purchases/{lookupBy}/{identifier}/transactions` (operationId `getTransactions`)
OpenAPI spec: https://docs.sparklayer.io/openapi/purchasing.yaml

Returns the transactions, such as payments and refunds, recorded against the purchase that matches `lookupBy` and `identifier`, including those stored for information only. Returns `404` if no purchase matches.

`GET /api/v1/purchases/{lookupBy}/{identifier}/transactions`

**Base URLs:** `https://app.sparklayer.io` (Live), `https://test.app.sparklayer.io` (Test)

**Authentication:** send `Authorization: Bearer <access_token>` and `Site-Id: <site id>` with every request. Get the token from [Get an access token](https://docs.sparklayer.io/developers/api/core/get-an-access-token.md); see [Authentication](https://docs.sparklayer.io/developers/authentication.md).

### Example request

```bash
curl "https://app.sparklayer.io/api/v1/purchases/platform/123456789/transactions" \
  -H "Authorization: Bearer $SPARKLAYER_TOKEN" \
  -H "Site-Id: $SPARKLAYER_SITE_ID"
```

Set `SPARKLAYER_TOKEN` to an access token and `SPARKLAYER_SITE_ID` to your Site ID. For the test environment, use `https://test.app.sparklayer.io`.

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `lookupBy` | "sparklayer" \| "platform" \| "internal" \| "visible" | Yes | Which of the purchase's `purchase_identifiers` `identifier` is: `sparklayer`, `platform`, `internal` or `visible`. Example: `platform` |
| `identifier` | string \| string (uuid) | Yes | The purchase identifier, of the kind set by `lookupBy`. With `lookupBy=sparklayer` it must be a UUID. Example: `123456789` |

### Header parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Site-Id` | string | Yes | Your SparkLayer Site ID, from Settings > API in the SparkLayer Dashboard. Length: min 1. Example: `jones-climbing` |

### Responses

#### 200: The transactions recorded against the purchase.

An array. Each item:

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `[].id` | string (uuid) \| null | | The identifier SparkLayer uses for the transaction. Length: min 1. |
| `[].purchase_spark_id` | string (uuid) \| null | | The identifier SparkLayer uses for the purchase. Length: min 1. |
| `[].platform_id` | string | | The identifier for this transaction on the e-commerce platform. Length: min 1. |
| `[].full_transaction` | string | | A JSON string representing the full details of the transaction |
| `[].type` | string | | The type of the transaction e.g. charge, refund |
| `[].apply_to_balance` | boolean | | Set to true to signal that the value of this transaction should contribute to customer balances |
| `[].currency_code` | string | | The 3 letter currency code used in this transaction. Length: min 3, max 3. |
| `[].total` | string | | The amount of this transaction |
| `[].transaction_date` | string (date-time) | | The date the transaction was created |
| `[].created_at` | string (date-time) | | The date the transaction was created in SparkLayer (RFC-3339). This is read only - it should not be sent to the API, but will be returned from it |

```json
[
  {
    "id": "63428136-658f-48a6-beb7-7f333dfd9686",
    "purchase_spark_id": "63428136-658f-48a6-beb7-7f333dfd9686",
    "platform_id": "123456789",
    "full_transaction": "<full_transaction>",
    "type": "<type>",
    "apply_to_balance": true,
    "currency_code": "GBP",
    "total": "20.99",
    "transaction_date": "2020-01-01T00:00:00+02:00",
    "created_at": "2020-01-01T00:00:00+02:00"
  }
]
```

#### 404: Not found.

`application/problem+json`: the standard error body (below).

#### 500: An unexpected error.

`application/problem+json`: the standard error body (below).

### Error body

Error responses with a body use this RFC 7807 problem details object. See [Errors](https://docs.sparklayer.io/developers/errors.md) for every status code and which errors to retry.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `detail` | string | | Human-readable summary of the error |
| `status` | integer | | HTTP Status code returned from API |
| `title` | string | | Machine-readable error code |
| `type` | string | | |
| `errors` | object[] | | |
| `errors[].code` | string | | A machine-readable error message |
| `errors[].property` | string | | The offending property |
| `errors[].message` | string | | A human-readable summary of the error |

```json
{
  "detail": "Data Validation Failed",
  "status": 400,
  "title": "invalid-api-request-contents",
  "type": "https://hub.sparklayer.io/tech-docs",
  "errors": [
    {
      "code": "unique-constraint-violation",
      "property": "purchase_identifiers.sparklayer",
      "message": "Each stock level must have a unique stock location and sku combination"
    }
  ]
}
```
