# API: Giving

| Method | Path | What it does | Scope |
|---|---|---|---|
| GET | `/v1/church/giving/accounting` | A file for the church's books: one balanced entry for each deposit, by fund (web app only) | `giving:read` |
| GET | `/v1/church/giving/accounts` | What the accounting file calls the bank, fees and other accounts | `giving:read` |
| PUT | `/v1/church/giving/accounts` | Name those accounts the way the church's books do | `giving:write` |
| GET | `/v1/church/giving/batches` | Batches, newest first, with what's in each | `giving:read` |
| POST | `/v1/church/giving/batches` | Start a batch | `giving:write` |
| GET | `/v1/church/giving/batches/:id` | A batch and its total so far | `giving:read` |
| PATCH | `/v1/church/giving/batches/:id` | Change an open batch's name, date or expected total, or remove one with no gifts in it | `giving:write` |
| POST | `/v1/church/giving/batches/:id/close` | Close a batch once its total matches the counting sheet, or say why it doesn't | `giving:write` |
| POST | `/v1/church/giving/batches/:id/reopen` | Reopen a closed batch to add or take out gifts | `giving:write` |
| POST | `/v1/church/giving/checks/read` | Read a check a scanner typed: its number, and whose it was last time. The account number isn't kept (web app only) | `giving:write` |
| GET | `/v1/church/giving/deposits` | Deposits, newest first, with fees, refunds and funds in each | `giving:read` |
| POST | `/v1/church/giving/deposits` | Record a bank deposit of one or more closed batches | `giving:write` |
| PATCH | `/v1/church/giving/deposits/:id` | Mark a deposit matched to the bank, or correct or remove one recorded by hand | `giving:write` |
| GET | `/v1/church/giving/funds` | The funds people can give to | `giving:read` |
| POST | `/v1/church/giving/funds` | Add a fund | `giving:write` |
| PATCH | `/v1/church/giving/funds/:id` | Change a fund, archive it or bring it back. Gifts already made to it stay | `giving:write` |
| GET | `/v1/church/giving/gifts` | Gifts, newest first, with the total of those that match | `giving:read` |
| POST | `/v1/church/giving/gifts` | Record a gift that came by cash, check or another way. Sending the same request_key twice records it once | `giving:write` |
| GET | `/v1/church/giving/gifts/:id` | A gift and what was changed on it | `giving:read` |
| PATCH | `/v1/church/giving/gifts/:id` | Correct a gift. One in a closed batch needs a reason; what it said before is kept | `giving:write` |
| POST | `/v1/church/giving/gifts/:id/refund` | Refund all or part of a gift paid online (web app only) | `giving:write` |
| POST | `/v1/church/giving/gifts/:id/void` | Void a gift recorded by mistake, or restore it. It stays in the history and leaves every total | `giving:write` |
| GET | `/v1/church/giving/givers` | Find who a gift is from, by name, email or phone | `giving:write` |
| POST | `/v1/church/giving/givers/:id/email` | Confirm that an address is this person's, so their statement goes there and they can see their own giving (web app only) | `giving:write` |
| GET | `/v1/church/giving/imports` | Files of past gifts brought in, newest first (web app only) | `giving:read` |
| POST | `/v1/church/giving/imports` | Bring past gifts in from a file. Without `commit` it only says what would happen (web app only) | `giving:write` |
| POST | `/v1/church/giving/imports/:id/undo` | Undo an import: every gift it added is voided (web app only) | `giving:write` |
| GET | `/v1/church/giving/online` | Whether people can give online, the page's address, and what Stripe charges | `giving:read` |
| PUT | `/v1/church/giving/online` | Turn the giving page on or off, and set what it says and offers | `giving:write` |
| POST | `/v1/church/giving/online/connect` | Start or carry on connecting the church's own Stripe account: answers with Stripe's page to open (web app only) | `giving:write` |
| GET | `/v1/church/giving/pledges` | Pledge campaigns, with what was pledged and given | `giving:read` |
| POST | `/v1/church/giving/pledges` | Start a pledge campaign for a fund | `giving:write` |
| GET | `/v1/church/giving/pledges/:id` | A campaign, each pledge, and what's been given toward it | `giving:read` |
| PATCH | `/v1/church/giving/pledges/:id` | Change, close or reopen a campaign | `giving:write` |
| PUT | `/v1/church/giving/pledges/:id/people` | Record what someone pledged, or change or take it out (amount null) | `giving:write` |
| GET | `/v1/church/giving/readers` | The church's card readers, each with the link for the tablet beside it (web app only) | `giving:read` |
| POST | `/v1/church/giving/readers` | Pair a Stripe card reader with the code it shows (web app only) | `giving:write` |
| PATCH | `/v1/church/giving/readers/:id` | Rename a card reader, replace its tablet's link, or stop using it (web app only) | `giving:write` |
| GET | `/v1/church/giving/repeating` | Repeating gifts and when each comes next | `giving:read` |
| PATCH | `/v1/church/giving/repeating/:id` | Pause, restart or stop someone's repeating gift. Only the giver changes its amount | `giving:write` |
| GET | `/v1/church/giving/reports` | Giving over a period, beside the same length of time before it | `giving:read` |
| GET | `/v1/church/giving/reports/gifts` | Every gift in a period as a spreadsheet (web app only) | `giving:read` |
| GET | `/v1/church/giving/statements` | Who gets a statement for a period, whether it was sent, and whether anything changed since (web app only) | `giving:read` |
| POST | `/v1/church/giving/statements/:id/withdraw` | Close the link in a statement sent to the wrong address (web app only) | `giving:write` |
| POST | `/v1/church/giving/statements/send` | Email statements to the people chosen (web app only) | `giving:write` |
| GET | `/v1/church/giving/statements/view` | Statements to read or print, as the gifts are now (web app only) | `giving:read` |
| GET | `/v1/church/giving/totals` | What was given to each fund between two dates, without who gave | `giving:read` |

## Examples

### GET /v1/church/giving/accounts

What the accounting file calls the bank, fees and other accounts

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

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

### PUT /v1/church/giving/accounts

Name those accounts the way the church's books do

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

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

### GET /v1/church/giving/batches

Batches, newest first, with what's in each

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

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

### POST /v1/church/giving/batches

Start a batch

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

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

A batch and its total so far

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

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

### PATCH /v1/church/giving/batches/$ID

Change an open batch's name, date or expected total, or remove one with no gifts in it

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

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

### POST /v1/church/giving/batches/$ID/close

Close a batch once its total matches the counting sheet, or say why it doesn't

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

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

### POST /v1/church/giving/batches/$ID/reopen

Reopen a closed batch to add or take out gifts

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

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/giving/batches/${id}/reopen`, {
  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/giving/deposits

Deposits, newest first, with fees, refunds and funds in each

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

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

### POST /v1/church/giving/deposits

Record a bank deposit of one or more closed batches

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

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

Mark a deposit matched to the bank, or correct or remove one recorded by hand

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

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

The funds people can give to

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

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

### POST /v1/church/giving/funds

Add a fund

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

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

Change a fund, archive it or bring it back. Gifts already made to it stay

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

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

Gifts, newest first, with the total of those that match

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

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

### POST /v1/church/giving/gifts

Record a gift that came by cash, check or another way. Sending the same request_key twice records it once

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

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

A gift and what was changed on it

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

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

### PATCH /v1/church/giving/gifts/$ID

Correct a gift. One in a closed batch needs a reason; what it said before is kept

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

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

### POST /v1/church/giving/gifts/$ID/void

Void a gift recorded by mistake, or restore it. It stays in the history and leaves every total

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

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/giving/gifts/${id}/void`, {
  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/giving/givers

Find who a gift is from, by name, email or phone

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

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

### GET /v1/church/giving/online

Whether people can give online, the page's address, and what Stripe charges

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

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

### PUT /v1/church/giving/online

Turn the giving page on or off, and set what it says and offers

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

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

### GET /v1/church/giving/pledges

Pledge campaigns, with what was pledged and given

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

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

### POST /v1/church/giving/pledges

Start a pledge campaign for a fund

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

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

A campaign, each pledge, and what's been given toward it

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

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

### PATCH /v1/church/giving/pledges/$ID

Change, close or reopen a campaign

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

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

Record what someone pledged, or change or take it out (amount null)

```bash
curl -s -X PUT "https://api.chapelwren.com/v1/church/giving/pledges/$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/giving/pledges/${id}/people`, {
  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();
```

### GET /v1/church/giving/repeating

Repeating gifts and when each comes next

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

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

### PATCH /v1/church/giving/repeating/$ID

Pause, restart or stop someone's repeating gift. Only the giver changes its amount

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

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

Giving over a period, beside the same length of time before it

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

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

### GET /v1/church/giving/totals

What was given to each fund between two dates, without who gave

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

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/giving/totals`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.CG_API_KEY}` },
});
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).
