# API: Website and app

| Method | Path | What it does | Scope |
|---|---|---|---|
| GET | `/v1/church/website/domains` | Your own domains, and the records each needs | `website:read` |
| POST | `/v1/church/website/domains` | Add a domain you own. It shows your site once its records prove it's yours (web app only) | `website:write` |
| DELETE | `/v1/church/website/domains/:id` | Disconnect a domain. Your site's own address keeps working (web app only) | `website:write` |
| POST | `/v1/church/website/domains/:id/check` | Check a domain's records, and connect it when they're right (web app only) | `website:write` |
| GET | `/v1/church/website/export` | The whole website as a file (JSON): details, pages and redirects | `website:read` |
| GET | `/v1/church/website/notices` | Notices on your site and app, and how many phones asked for them | `website:read` |
| POST | `/v1/church/website/notices` | Show a notice on your site and app. No phone buzzes unless someone then presses Send (web app only) | `website:write` |
| DELETE | `/v1/church/website/notices/:id` | Remove a notice. A send that's still going stops (web app only) | `website:write` |
| PATCH | `/v1/church/website/notices/:id` | Change a notice, or stop showing it (web app only) | `website:write` |
| POST | `/v1/church/website/notices/:id/push` | Send a notice to the phones that asked for notices like it. Once for each notice, three a day (web app only) | `website:write` |
| PUT | `/v1/church/website/page-order` | Put the pages in this order in the menu | `website:write` |
| GET | `/v1/church/website/pages` | Pages you removed, so they can be put back | `website:read` |
| POST | `/v1/church/website/pages` | Add a page to the draft | `website:write` |
| DELETE | `/v1/church/website/pages/:id` | Remove a page from the draft. It can be put back | `website:write` |
| GET | `/v1/church/website/pages/:id` | One page's draft, block by block | `website:read` |
| PATCH | `/v1/church/website/pages/:id` | Change a page's draft. Send the `rev` you read, so nobody's work is lost | `website:write` |
| POST | `/v1/church/website/pages/:id/restore` | Put a removed page back in the draft | `website:write` |
| GET | `/v1/church/website/posts` | Your blog's posts and drafts, newest first | `website:read` |
| POST | `/v1/church/website/posts` | Write a post. It's a draft unless a person publishes it | `website:write` |
| DELETE | `/v1/church/website/posts/:id` | Remove a post. It can be put back (web app only) | `website:write` |
| GET | `/v1/church/website/posts/:id` | One post, with its words | `website:read` |
| PATCH | `/v1/church/website/posts/:id` | Change a post. `publish: false` takes it off the site; `removed: false` puts a removed one back | `website:write` |
| POST | `/v1/church/website/preview` | How a page will look, with changes that aren't saved yet | `website:read` |
| GET | `/v1/church/website/preview.css` | The look's stylesheet, for the preview | `website:read` |
| POST | `/v1/church/website/publish` | Put the draft online, for everyone (web app only) | `website:write` |
| GET | `/v1/church/website/reading-plans` | Your Bible reading plans | `website:read` |
| POST | `/v1/church/website/reading-plans` | Make a reading plan: one line of passages for each day | `website:write` |
| DELETE | `/v1/church/website/reading-plans/:id` | Remove a reading plan. It can be put back (web app only) | `website:write` |
| GET | `/v1/church/website/reading-plans/:id` | One reading plan, with its days | `website:read` |
| PATCH | `/v1/church/website/reading-plans/:id` | Change a reading plan. `removed: false` puts a removed one back | `website:write` |
| GET | `/v1/church/website/reading-plans/starters` | Ready-made plans to start from | `website:read` |
| GET | `/v1/church/website/redirects` | Old addresses and where they lead now | `website:read` |
| PUT | `/v1/church/website/redirects` | Send an old address somewhere else. It works at once (web app only) | `website:write` |
| DELETE | `/v1/church/website/redirects/:id` | Remove a redirect (web app only) | `website:write` |
| GET | `/v1/church/website/site` | Your website: its address, details and look, its pages, and whether there are changes to publish | `website:read` |
| PATCH | `/v1/church/website/site` | Change the website's details, look, app or address. Details show once you publish; a new address works at once | `website:write` |
| POST | `/v1/church/website/site` | Make a website from your church's name, address and service times. Nobody sees it until you publish | `website:write` |
| POST | `/v1/church/website/unpublish` | Take the whole website and app offline. Your draft stays (web app only) | `website:write` |
| GET | `/v1/church/website/versions` | What you've published, newest first (the last 50) | `website:read` |
| POST | `/v1/church/website/versions/:id/restore` | Make the draft what it was in an earlier version. Publish to put it online (web app only) | `website:write` |

## Examples

### GET /v1/church/website/domains

Your own domains, and the records each needs

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

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

### GET /v1/church/website/export

The whole website as a file (JSON): details, pages and redirects

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

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

### GET /v1/church/website/notices

Notices on your site and app, and how many phones asked for them

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

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

### PUT /v1/church/website/page-order

Put the pages in this order in the menu

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

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/website/page-order`, {
  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/website/pages

Pages you removed, so they can be put back

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

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

### POST /v1/church/website/pages

Add a page to the draft

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

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

Remove a page from the draft. It can be put back

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

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

### GET /v1/church/website/pages/$ID

One page's draft, block by block

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

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

### PATCH /v1/church/website/pages/$ID

Change a page's draft. Send the `rev` you read, so nobody's work is lost

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

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

Put a removed page back in the draft

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

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/website/pages/${id}/restore`, {
  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/website/posts

Your blog's posts and drafts, newest first

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

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

### POST /v1/church/website/posts

Write a post. It's a draft unless a person publishes it

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

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

One post, with its words

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

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

### PATCH /v1/church/website/posts/$ID

Change a post. `publish: false` takes it off the site; `removed: false` puts a removed one back

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

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

How a page will look, with changes that aren't saved yet

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

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

The look's stylesheet, for the preview

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

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

### GET /v1/church/website/reading-plans

Your Bible reading plans

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

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

### POST /v1/church/website/reading-plans

Make a reading plan: one line of passages for each day

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

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

One reading plan, with its days

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

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

### PATCH /v1/church/website/reading-plans/$ID

Change a reading plan. `removed: false` puts a removed one back

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

```js
const res = await fetch(`https://api.chapelwren.com/v1/church/website/reading-plans/${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/website/reading-plans/starters

Ready-made plans to start from

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

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

### GET /v1/church/website/redirects

Old addresses and where they lead now

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

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

### GET /v1/church/website/site

Your website: its address, details and look, its pages, and whether there are changes to publish

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

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

### PATCH /v1/church/website/site

Change the website's details, look, app or address. Details show once you publish; a new address works at once

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

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

Make a website from your church's name, address and service times. Nobody sees it until you publish

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

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

What you've published, newest first (the last 50)

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

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