---
title: "Create a charities selection"
description: "POST /v1/charities-selections"
canonical: https://www.charitips.com/docs/api-reference/create-charities-selection
---

# Create a charities selection

`POST /v1/charities-selections`

**Authentication**: Bearer access token.

## Body

- `name` (string, required, 2 to 100 characters): Name of the selection.
- `charityIds` (string[], UUID): Ids of the selected charities.
- `campaignId` (string, UUID): Optionally link it directly to an existing campaign.
- `accountId` (string, UUID): Only required to link the created entity to a child account instead of the current one.
- `featuredCharitiesIds` (string[], UUID): Ids of the featured charities. These charities will be displayed first in the list of charities. Warning: The featured charities must be part of the selected charities.

## Response 201

- `charitiesSelectionId` (string, required)
- `name` (string, required)
- `type` (CharitiesSelectionType, required) One of `GENERIC`, `CUSTOM`.
- `featuredCharitiesIds` (string[], required)
- `isFeatured` (boolean, required)
- `accountId` (string)
- `authorId` (string)
- `createdAt` (string (date-time), required)
- `updatedAt` (string (date-time), required)
- `charities` (OnlyCharityId[], required)
  - `charityId` (string, required)

## Errors

- 400 `A selection must have at least one charity to be linked to a campaign`: You sent `campaignId`: pass at least one id in `charityIds` as well, or create the selection without `campaignId`. See https://www.charitips.com/docs/api-reference/create-charities-selection.md.
- 400 `Featured charities must be part of the selected charities: <join(', ')>`: `featuredCharitiesIds` names charities that are not in the selection: the message lists them. Add them to `charityIds`, or leave them out of `featuredCharitiesIds`. See https://www.charitips.com/docs/concepts/charities.md#your-own-selections.
- 400 `A field is missing, has the wrong type, or is not part of the request schema.`: `message` lists every problem. Unknown fields are rejected, not ignored: remove them rather than sending extra data. See https://www.charitips.com/docs/api-reference/errors.md.
- 401 `Unauthorized`: The access token is missing, expired or invalid. Create a new one with your client id and secret, send it as `Authorization: Bearer <accessToken>`, then retry once. Sandbox tokens only work on api.sandbox.charitips.com. See https://www.charitips.com/docs/get-started/authentication.md.
- 403 `Account closed`: The account behind these credentials is closed: no token is issued and every call is refused, reads included. Contact Charitips to reopen it. See https://www.charitips.com/docs/api-reference/troubleshooting.md#calls-answer-403-account-not-active-account-not-validated-or-account-closed.

## Example

```bash
curl -X POST https://api.sandbox.charitips.com/v1/charities-selections \
  -H "Authorization: Bearer $CHARITIPS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Checkout charities",
    "charityIds": [
      "<charityId>"
    ]
  }'
```

```javascript
const response = await fetch('https://api.sandbox.charitips.com/v1/charities-selections', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.CHARITIPS_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "name": "Checkout charities",
    "charityIds": [
      "<charityId>"
    ]
  }),
});
if (!response.ok) throw new Error(`${response.status} ${await response.text()}`);
const data = await response.json();
```

```python
import os, requests

response = requests.post(
    "https://api.sandbox.charitips.com/v1/charities-selections",
    headers={"Authorization": f"Bearer {os.environ['CHARITIPS_TOKEN']}"},
    json={
      "name": "Checkout charities",
      "charityIds": [
        "<charityId>"
      ]
    },
)
response.raise_for_status()
data = response.json()
```

## Response example (201, placeholder values)

```json
{
  "charitiesSelectionId": "<charitiesSelectionId>",
  "name": "<name>",
  "type": "GENERIC",
  "featuredCharitiesIds": [],
  "isFeatured": false,
  "accountId": "<accountId>",
  "authorId": "<authorId>",
  "createdAt": "<createdAt>"
}
```
