# Countries

## Prerequisites

* `access_token` from [headless-api-authentication](https://dev.ucommerce.net/readme/headless/headless-api-authentication "mention")

## Get Countries

### Optional Parameters

* `filterOnStore`, limits the result to Countries with available Shipping or Payment Methods available for the authenticated store [headless-api-authentication](https://dev.ucommerce.net/readme/headless/headless-api-authentication "mention")
* `maxItems`, limits the number of results returned. in [pagination](https://dev.ucommerce.net/readme/headless/pagination "mention")
* `nextPagingToken`, required to fetch the next page. Read more in [pagination](https://dev.ucommerce.net/readme/headless/pagination "mention")

### Request

```bash
curl -D- -X POST <base_url>/api/v1/countries?filterOnStore=false&maxItems=<maxItems>&nextPagingToken=<nextPagingToken> \
    -H 'Authorization: Bearer <ACCESS_TOKEN>'
    -H 'Content-Type: application/json' \
```

### Response

```json
{
    "countries": [
        {
            "cultureCode": "{cultureCode}",
            "id": "{countryId}",
            "name": "{countryName}"
        }
    ],
    "nextPagingToken": "{nextPagingToken | null}"
}
```

## Error Handling

| Error              | Description                                      |
| ------------------ | ------------------------------------------------ |
| Unauthorized (401) | The token is expired.                            |
| Forbidden (403)    | The token does not have access to this endpoint. |

Error Response Example

```json
{
"errors":
    [
        {
            "error-description": "The token is expired.",
            "error": "Unauthorized"
        }
    ]
}
```

## Related Articles

{% content-ref url="../error-handling" %}
[error-handling](https://dev.ucommerce.net/readme/headless/error-handling)
{% endcontent-ref %}
