# API: Events

| Method | Path | What it does | Scope |
|---|---|---|---|
| GET | `/v1/church/events` | Events, and each date they're on between two days (the next 60 days unless you say) | `events:read` |
| POST | `/v1/church/events` | Add an event. Leave the times out for all day | `events:write` |
| GET | `/v1/church/events/:id` | One event: its dates, rooms, tickets and questions | `events:read` |
| PATCH | `/v1/church/events/:id` | Change an event, take it off the calendar, or put it back. Its rooms move with it | `events:write` |
| POST | `/v1/church/events/:id/ask-for-balance` | Email everyone who still owes for an event, with a link to pay. Once a day at most (web app only) | `events:write` |
| PUT | `/v1/church/events/:id/dates/:day` | Call off or move one date of an event, or put it back (send nothing) | `events:write` |
| DELETE | `/v1/church/events/:id/rooms/:room` | Give a room back | `events:write` |
| PUT | `/v1/church/events/:id/rooms/:room` | Book a room for every date of an event, with time to set up and clear. One that needs a yes is asked for | `events:write` |
| PUT | `/v1/church/events/:id/signup` | How people sign up for an event: places, tickets, questions, codes and when the rest is due. Leaving a ticket or code out takes it away for new people | `events:write` |
| GET | `/v1/church/events/:id/signups` | Everyone who signed up for an event, with who came and what's owed (web app only) | `events:read` |
| POST | `/v1/church/events/:id/signups` | Sign someone up at the office or the door. `over` goes past the limit; `waiting` puts them on the waiting list (web app only) | `events:write` |
| POST | `/v1/church/events/bookings/:id` | Say yes or no to a room someone asked for | `events:write` |
| PATCH | `/v1/church/events/guests/:id` | Correct a guest's name, ticket or answers, take them off, or put them back (web app only) | `events:write` |
| PUT | `/v1/church/events/guests/:id/here` | Check a guest in on a day, or undo it (web app only) | `events:read` |
| POST | `/v1/church/events/guests/:id/person` | Keep a guest in People: finds their record, or adds them as a visitor (web app only) | `events:write` |
| GET | `/v1/church/events/guests/:id/private` | Open a guest's private answers. Each opening is recorded (web app only) | `events:read` |
| DELETE | `/v1/church/events/payments/:id` | Take off a cash, check or other payment recorded by mistake (web app only) | `events:write` |
| POST | `/v1/church/events/payments/:id/refund` | Give money back. A card payment goes back to the card; for cash or a check this writes it down (web app only) | `events:write` |
| GET | `/v1/church/events/rooms` | Rooms and equipment, what's booked on a day, and who's waiting for a yes | `events:read` |
| POST | `/v1/church/events/rooms` | Add a room or a piece of equipment people can book | `events:write` |
| PATCH | `/v1/church/events/rooms/:id` | Change a room, or take it off the list. What's booked in it stays on those events | `events:write` |
| PATCH | `/v1/church/events/signups/:id` | Correct a sign-up, cancel it, bring it back, or give someone waiting a place (web app only) | `events:write` |
| POST | `/v1/church/events/signups/:id/guests` | Add someone to a sign-up (web app only) | `events:write` |
| POST | `/v1/church/events/signups/:id/payments` | Record cash, a check or another payment for a sign-up (web app only) | `events:write` |

## Examples

### GET /v1/church/events

Events, and each date they're on between two days (the next 60 days unless you say)

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

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

### POST /v1/church/events

Add an event. Leave the times out for all day

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

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/events`, {
  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/events/$ID

One event: its dates, rooms, tickets and questions

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

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

### PATCH /v1/church/events/$ID

Change an event, take it off the calendar, or put it back. Its rooms move with it

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

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/events/${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();
```

### PUT /v1/church/events/$ID/dates/$DAY

Call off or move one date of an event, or put it back (send nothing)

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

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/events/${id}/dates/${day}`, {
  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/events/$ID/rooms/$ROOM

Give a room back

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

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

### PUT /v1/church/events/$ID/rooms/$ROOM

Book a room for every date of an event, with time to set up and clear. One that needs a yes is asked for

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

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/events/${id}/rooms/${room}`, {
  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/events/$ID/signup

How people sign up for an event: places, tickets, questions, codes and when the rest is due. Leaving a ticket or code out takes it away for new people

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

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/events/${id}/signup`, {
  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/events/bookings/$ID

Say yes or no to a room someone asked for

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

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/events/bookings/${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();
```

### GET /v1/church/events/rooms

Rooms and equipment, what's booked on a day, and who's waiting for a yes

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

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

### POST /v1/church/events/rooms

Add a room or a piece of equipment people can book

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

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/events/rooms`, {
  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/events/rooms/$ID

Change a room, or take it off the list. What's booked in it stays on those events

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

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/events/rooms/${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();
```

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).
