# API: Serving

| Method | Path | What it does | Scope |
|---|---|---|---|
| GET | `/v1/church/serving/attendance` | Service attendance, newest first, with the people named lately | `serving:read` |
| PUT | `/v1/church/serving/attendance` | Save how many came to a service, or who did. `id` corrects one you already have | `serving:write` |
| DELETE | `/v1/church/serving/attendance/:id` | Remove one service's attendance | `serving:write` |
| DELETE | `/v1/church/serving/away/:id` | Take back days someone was away | `serving:write` |
| POST | `/v1/church/serving/away/:id` | Write down days someone is away | `serving:write` |
| DELETE | `/v1/church/serving/files/:id` | Remove a song's file | `serving:write` |
| GET | `/v1/church/serving/files/:id` | A song's file (web app only) | `serving:read` |
| DELETE | `/v1/church/serving/people/:id` | Take someone off a service. Anyone already asked gets an email (web app only) | `serving:write` |
| PATCH | `/v1/church/serving/people/:id` | Write down what someone told you: yes or no. Or ask their team to take their place (web app only) | `serving:write` |
| GET | `/v1/church/serving/services` | Coming services (or past ones, or templates), with how many people said yes | `serving:read` |
| POST | `/v1/church/serving/services` | Add a service, one for each of the next weeks, or a template. `from_id` copies a run sheet | `serving:write` |
| GET | `/v1/church/serving/services/:id` | A service: its run sheet, who serves in each position, and who could | `serving:read` |
| PATCH | `/v1/church/serving/services/:id` | Change a service. Removing one tells the people who were asked (web app only) | `serving:write` |
| POST | `/v1/church/serving/services/:id/ask` | Email everyone chosen and not yet asked. Says who has no email (web app only) | `serving:write` |
| POST | `/v1/church/serving/services/:id/fill` | Fill the empty places with whoever served longest ago and isn't away | `serving:write` |
| PUT | `/v1/church/serving/services/:id/items` | Save the run sheet. `version` is the one you opened, so two people never undo each other's changes | `serving:write` |
| PUT | `/v1/church/serving/services/:id/needs/:place` | How many people a position needs at this service | `serving:write` |
| POST | `/v1/church/serving/services/:id/people` | Put someone on a service. They hear nothing until you ask them | `serving:write` |
| GET | `/v1/church/serving/songs` | Songs, with when each was last used | `serving:read` |
| POST | `/v1/church/serving/songs` | Add a song your church is licensed to use | `serving:write` |
| GET | `/v1/church/serving/songs/:id` | A song: its words, files, and the services it was in | `serving:read` |
| PATCH | `/v1/church/serving/songs/:id` | Change a song, or remove it and bring it back | `serving:write` |
| POST | `/v1/church/serving/songs/:id/files` | Add sheet music, chords or a recording to a song (up to 5 MB) (web app only) | `serving:write` |
| GET | `/v1/church/serving/teams` | Teams, their positions, who's on them and when they're away | `serving:read` |
| POST | `/v1/church/serving/teams` | Add a team and its positions | `serving:write` |
| PATCH | `/v1/church/serving/teams/:id` | Change a team and its positions, or remove it and bring it back | `serving:write` |
| DELETE | `/v1/church/serving/teams/:id/people/:person` | Take someone off a team. Services they're already on stay as they are | `serving:write` |
| PUT | `/v1/church/serving/teams/:id/people/:person` | Put someone on a team, and say which positions they do (none named means any) | `serving:write` |

## Examples

### GET /v1/church/serving/attendance

Service attendance, newest first, with the people named lately

```bash
curl -s "https://api.chapelwren.com/v1/church/serving/attendance" \
  -H "Authorization: Bearer $CG_API_KEY"
```

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/serving/attendance`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}` },
});
const data = await res.json();
```

### PUT /v1/church/serving/attendance

Save how many came to a service, or who did. `id` corrects one you already have

```bash
curl -s -X PUT "https://api.chapelwren.com/v1/church/serving/attendance" \
  -H "Authorization: Bearer $CG_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/serving/attendance`, {
  method: "PUT",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

### DELETE /v1/church/serving/attendance/$ID

Remove one service's attendance

```bash
curl -s -X DELETE "https://api.chapelwren.com/v1/church/serving/attendance/$ID" \
  -H "Authorization: Bearer $CG_API_KEY"
```

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/serving/attendance/${id}`, {
  method: "DELETE",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}` },
});
const data = await res.json();
```

### DELETE /v1/church/serving/away/$ID

Take back days someone was away

```bash
curl -s -X DELETE "https://api.chapelwren.com/v1/church/serving/away/$ID" \
  -H "Authorization: Bearer $CG_API_KEY"
```

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/serving/away/${id}`, {
  method: "DELETE",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}` },
});
const data = await res.json();
```

### POST /v1/church/serving/away/$ID

Write down days someone is away

```bash
curl -s -X POST "https://api.chapelwren.com/v1/church/serving/away/$ID" \
  -H "Authorization: Bearer $CG_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/serving/away/${id}`, {
  method: "POST",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

### DELETE /v1/church/serving/files/$ID

Remove a song's file

```bash
curl -s -X DELETE "https://api.chapelwren.com/v1/church/serving/files/$ID" \
  -H "Authorization: Bearer $CG_API_KEY"
```

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/serving/files/${id}`, {
  method: "DELETE",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}` },
});
const data = await res.json();
```

### GET /v1/church/serving/services

Coming services (or past ones, or templates), with how many people said yes

```bash
curl -s "https://api.chapelwren.com/v1/church/serving/services" \
  -H "Authorization: Bearer $CG_API_KEY"
```

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/serving/services`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}` },
});
const data = await res.json();
```

### POST /v1/church/serving/services

Add a service, one for each of the next weeks, or a template. `from_id` copies a run sheet

```bash
curl -s -X POST "https://api.chapelwren.com/v1/church/serving/services" \
  -H "Authorization: Bearer $CG_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/serving/services`, {
  method: "POST",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

### GET /v1/church/serving/services/$ID

A service: its run sheet, who serves in each position, and who could

```bash
curl -s "https://api.chapelwren.com/v1/church/serving/services/$ID" \
  -H "Authorization: Bearer $CG_API_KEY"
```

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/serving/services/${id}`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}` },
});
const data = await res.json();
```

### POST /v1/church/serving/services/$ID/fill

Fill the empty places with whoever served longest ago and isn't away

```bash
curl -s -X POST "https://api.chapelwren.com/v1/church/serving/services/$ID/fill" \
  -H "Authorization: Bearer $CG_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/serving/services/${id}/fill`, {
  method: "POST",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

### PUT /v1/church/serving/services/$ID/items

Save the run sheet. `version` is the one you opened, so two people never undo each other's changes

```bash
curl -s -X PUT "https://api.chapelwren.com/v1/church/serving/services/$ID/items" \
  -H "Authorization: Bearer $CG_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/serving/services/${id}/items`, {
  method: "PUT",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

### PUT /v1/church/serving/services/$ID/needs/$PLACE

How many people a position needs at this service

```bash
curl -s -X PUT "https://api.chapelwren.com/v1/church/serving/services/$ID/needs/$PLACE" \
  -H "Authorization: Bearer $CG_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/serving/services/${id}/needs/${place}`, {
  method: "PUT",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

### POST /v1/church/serving/services/$ID/people

Put someone on a service. They hear nothing until you ask them

```bash
curl -s -X POST "https://api.chapelwren.com/v1/church/serving/services/$ID/people" \
  -H "Authorization: Bearer $CG_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/serving/services/${id}/people`, {
  method: "POST",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

### GET /v1/church/serving/songs

Songs, with when each was last used

```bash
curl -s "https://api.chapelwren.com/v1/church/serving/songs" \
  -H "Authorization: Bearer $CG_API_KEY"
```

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/serving/songs`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}` },
});
const data = await res.json();
```

### POST /v1/church/serving/songs

Add a song your church is licensed to use

```bash
curl -s -X POST "https://api.chapelwren.com/v1/church/serving/songs" \
  -H "Authorization: Bearer $CG_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/serving/songs`, {
  method: "POST",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

### GET /v1/church/serving/songs/$ID

A song: its words, files, and the services it was in

```bash
curl -s "https://api.chapelwren.com/v1/church/serving/songs/$ID" \
  -H "Authorization: Bearer $CG_API_KEY"
```

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/serving/songs/${id}`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}` },
});
const data = await res.json();
```

### PATCH /v1/church/serving/songs/$ID

Change a song, or remove it and bring it back

```bash
curl -s -X PATCH "https://api.chapelwren.com/v1/church/serving/songs/$ID" \
  -H "Authorization: Bearer $CG_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/serving/songs/${id}`, {
  method: "PATCH",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

### GET /v1/church/serving/teams

Teams, their positions, who's on them and when they're away

```bash
curl -s "https://api.chapelwren.com/v1/church/serving/teams" \
  -H "Authorization: Bearer $CG_API_KEY"
```

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/serving/teams`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}` },
});
const data = await res.json();
```

### POST /v1/church/serving/teams

Add a team and its positions

```bash
curl -s -X POST "https://api.chapelwren.com/v1/church/serving/teams" \
  -H "Authorization: Bearer $CG_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/serving/teams`, {
  method: "POST",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

### PATCH /v1/church/serving/teams/$ID

Change a team and its positions, or remove it and bring it back

```bash
curl -s -X PATCH "https://api.chapelwren.com/v1/church/serving/teams/$ID" \
  -H "Authorization: Bearer $CG_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/serving/teams/${id}`, {
  method: "PATCH",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

### DELETE /v1/church/serving/teams/$ID/people/$PERSON

Take someone off a team. Services they're already on stay as they are

```bash
curl -s -X DELETE "https://api.chapelwren.com/v1/church/serving/teams/$ID/people/$PERSON" \
  -H "Authorization: Bearer $CG_API_KEY"
```

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/serving/teams/${id}/people/${person}`, {
  method: "DELETE",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}` },
});
const data = await res.json();
```

### PUT /v1/church/serving/teams/$ID/people/$PERSON

Put someone on a team, and say which positions they do (none named means any)

```bash
curl -s -X PUT "https://api.chapelwren.com/v1/church/serving/teams/$ID/people/$PERSON" \
  -H "Authorization: Bearer $CG_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/serving/teams/${id}/people/${person}`, {
  method: "PUT",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

Request and response schemas: [https://www.chapelwren.com/openapi.json](https://www.chapelwren.com/openapi.json). All resources: [API reference](https://www.chapelwren.com/docs/api).
