> For the complete documentation index, see [llms.txt](https://btwb.gitbook.io/btwb/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://btwb.gitbook.io/btwb/developers/api-reference.md).

# API Reference

### Base URL

**Production:** `https://admin.btwb.com`

All endpoints are prefixed with `/api/zapier`.

### Authentication

The API uses Bearer token authentication. Include your API key in the `Authorization` header:

```
Authorization: Bearer YOUR_API_KEY
```

Copy the full API key from Gym Tools > Zapier and use it as shown above.

### Pagination

All event endpoints support pagination using the `page` query parameter.

<table><thead><tr><th>Parameter</th><th>Type</th><th width="136">Default</th><th>Description</th></tr></thead><tbody><tr><td>page</td><td>integer</td><td>0</td><td>Page number (0-indexed)</td></tr></tbody></table>

**Behavior:**

* Each page returns up to **40 events**
* Events are returned in reverse chronological order (newest first)
* Page numbering starts at 0
* An empty array `[]` indicates no more events are available

**Pagination Strategy:**

1. Start with `page=0`
2. If the response contains 40 events, there may be more pages
3. Increment `page` and repeat until you receive fewer than 40 events or an empty array

### Error Responses

The API returns errors in [RFC 9457 Problem Details](https://www.rfc-editor.org/rfc/rfc9457.html) format with `Content-Type: application/problem+json`.

**Common Error Fields:**

| Field  | Type    | Description                           |
| ------ | ------- | ------------------------------------- |
| title  | string  | Short, human-readable error summary   |
| status | integer | HTTP status code                      |
| detail | string  | Human-readable explanation (optional) |
| errors | array   | Validation error details (422 only)   |

**401 Unauthorized** - Invalid or missing API key

```json
{
  "title": "Unauthorized",
  "status": 401,
  "detail": "Invalid API key"
}
```

**422 Unprocessable Entity** - Invalid request parameters

```json
{
  "title": "Validation Error",
  "status": 422,
  "detail": "One or more validation errors occurred",
  "errors": [
    {
      "detail": "expected an integer",
      "pointer": "page"
    }
  ]
}
```

**500 Internal Server Error** - Unexpected server error

```json
{
  "title": "Internal Server Error",
  "status": 500
}
```

***

### Endpoints

#### Test Authentication

```
GET /api/zapier/me
```

Returns the authenticated organization ID. Use this to verify your API key is working.

**Response:**

```json
{
  "organization_id": "00000000-0000-0002-0000-00000001a2b3"
}
```

**CURL Example:**

```bash
curl -X GET "https://admin.btwb.com/api/zapier/me" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

***

#### Client Events

**Client Added Events**

```
GET /api/zapier/gym/clients/client-added-events
```

Returns recent client creation events.

| Parameter | Type    | Default | Description             |
| --------- | ------- | ------- | ----------------------- |
| page      | integer | 0       | Page number (0-indexed) |

**CURL Example:**

```bash
curl -X GET "https://admin.btwb.com/api/zapier/gym/clients/client-added-events?page=0" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

**Response:**

```json
[
  {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "time": "2024-01-15T14:30:00Z",
    "data": {
      "organization_id": "00000000-0000-0002-0000-00000001a2b3",
      "client": {
        "id": "c1d2e3f4-a5b6-7890-cdef-123456789012",
        "member_id": "m1n2o3p4-q5r6-7890-stuv-wxyz12345678",
        "first_name": "John",
        "last_name": "Doe",
        "email": "john.doe@example.com"
      },
      "starting_connection_status": "lead"
    }
  }
]
```

***

**Client Archived Events**

```
GET /api/zapier/gym/clients/client-archived-events
```

Returns recent client archival events.

| Parameter | Type    | Default | Description             |
| --------- | ------- | ------- | ----------------------- |
| page      | integer | 0       | Page number (0-indexed) |

**CURL Example:**

```bash
curl -X GET "https://admin.btwb.com/api/zapier/gym/clients/client-archived-events?page=0" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

**Response:**

```json
[
  {
    "id": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
    "time": "2024-01-16T10:15:00Z",
    "data": {
      "organization_id": "00000000-0000-0002-0000-00000001a2b3",
      "client": {
        "id": "c1d2e3f4-a5b6-7890-cdef-123456789012",
        "member_id": "m1n2o3p4-q5r6-7890-stuv-wxyz12345678",
        "first_name": "John",
        "last_name": "Doe",
        "email": "john.doe@example.com"
      }
    }
  }
]
```

***

**Client Details Updated Events**

```
GET /api/zapier/gym/clients/client-details-updated-events
```

Returns recent client profile update events.

| Parameter | Type    | Default | Description             |
| --------- | ------- | ------- | ----------------------- |
| page      | integer | 0       | Page number (0-indexed) |

**CURL Example:**

```bash
curl -X GET "https://admin.btwb.com/api/zapier/gym/clients/client-details-updated-events?page=0" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

**Response:**

```json
[
  {
    "id": "c3d4e5f6-a7b8-9012-cdef-345678901234",
    "time": "2024-01-17T09:45:00Z",
    "data": {
      "organization_id": "00000000-0000-0002-0000-00000001a2b3",
      "client": {
        "id": "c1d2e3f4-a5b6-7890-cdef-123456789012",
        "member_id": "m1n2o3p4-q5r6-7890-stuv-wxyz12345678",
        "first_name": "John",
        "last_name": "Smith",
        "email": "john.smith@example.com"
      }
    }
  }
]
```

***

#### Scheduling Events

**Class Checked In Events**

```
GET /api/zapier/gym/scheduling/class-checked-in-events
```

Returns recent class check-in events.

| Parameter | Type    | Default | Description             |
| --------- | ------- | ------- | ----------------------- |
| page      | integer | 0       | Page number (0-indexed) |

**CURL Example:**

```bash
curl -X GET "https://admin.btwb.com/api/zapier/gym/scheduling/class-checked-in-events?page=0" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

**Response:**

```json
[
  {
    "id": "d4e5f6a7-b8c9-0123-defg-456789012345",
    "time": "2024-01-18T08:00:00Z",
    "data": {
      "organization_id": "00000000-0000-0002-0000-00000001a2b3",
      "client": {
        "id": "c1d2e3f4-a5b6-7890-cdef-123456789012",
        "member_id": "m1n2o3p4-q5r6-7890-stuv-wxyz12345678",
        "first_name": "John",
        "last_name": "Doe",
        "email": "john.doe@example.com"
      },
      "class": {
        "id": "cls-12345678-90ab-cdef-1234-567890abcdef",
        "name": "Morning CrossFit",
        "date": "2024-01-18",
        "time": "08:00:00"
      },
      "class_type": {
        "id": "ct-98765432-10fe-dcba-9876-543210fedcba",
        "name": "CrossFit"
      },
      "location": {
        "id": "loc-11111111-2222-3333-4444-555555555555",
        "name": "Main Gym"
      }
    }
  }
]
```

***

#### Membership Events

**Subscription Started Events**

```
GET /api/zapier/gym/membership/subscription-started-events
```

Returns recent subscription activation events.

| Parameter | Type    | Default | Description             |
| --------- | ------- | ------- | ----------------------- |
| page      | integer | 0       | Page number (0-indexed) |

**CURL Example:**

```bash
curl -X GET "https://admin.btwb.com/api/zapier/gym/membership/subscription-started-events?page=0" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

**Response:**

```json
[
  {
    "id": "e5f6a7b8-c9d0-1234-efgh-567890123456",
    "time": "2024-01-19T12:00:00Z",
    "data": {
      "organization_id": "00000000-0000-0002-0000-00000001a2b3",
      "client": {
        "id": "c1d2e3f4-a5b6-7890-cdef-123456789012",
        "member_id": "m1n2o3p4-q5r6-7890-stuv-wxyz12345678",
        "first_name": "John",
        "last_name": "Doe",
        "email": "john.doe@example.com"
      },
      "subscription": {
        "id": "sub-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
      },
      "membership_plan": {
        "id": "plan-11111111-2222-3333-4444-555555555555",
        "name": "Unlimited Monthly"
      }
    }
  }
]
```

***

**Subscription Canceled Events**

```
GET /api/zapier/gym/membership/subscription-canceled-events
```

Returns recent subscription cancellation events.

| Parameter | Type    | Default | Description             |
| --------- | ------- | ------- | ----------------------- |
| page      | integer | 0       | Page number (0-indexed) |

**CURL Example:**

```bash
curl -X GET "https://admin.btwb.com/api/zapier/gym/membership/subscription-canceled-events?page=0" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

**Response:**

```json
[
  {
    "id": "f6a7b8c9-d0e1-2345-fghi-678901234567",
    "time": "2024-01-20T15:30:00Z",
    "data": {
      "organization_id": "00000000-0000-0002-0000-00000001a2b3",
      "client": {
        "id": "c1d2e3f4-a5b6-7890-cdef-123456789012",
        "member_id": "m1n2o3p4-q5r6-7890-stuv-wxyz12345678",
        "first_name": "John",
        "last_name": "Doe",
        "email": "john.doe@example.com"
      },
      "subscription": {
        "id": "sub-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
      },
      "membership_plan": {
        "id": "plan-11111111-2222-3333-4444-555555555555",
        "name": "Unlimited Monthly"
      }
    }
  }
]
```

***

**Subscription Expired Events**

```
GET /api/zapier/gym/membership/subscription-expired-events
```

Returns recent subscription expiration events.

| Parameter | Type    | Default | Description             |
| --------- | ------- | ------- | ----------------------- |
| page      | integer | 0       | Page number (0-indexed) |

**CURL Example:**

```bash
curl -X GET "https://admin.btwb.com/api/zapier/gym/membership/subscription-expired-events?page=0" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

**Response:**

```json
[
  {
    "id": "a7b8c9d0-e1f2-3456-ghij-789012345678",
    "time": "2024-01-21T00:00:00Z",
    "data": {
      "organization_id": "00000000-0000-0002-0000-00000001a2b3",
      "client": {
        "id": "c1d2e3f4-a5b6-7890-cdef-123456789012",
        "member_id": "m1n2o3p4-q5r6-7890-stuv-wxyz12345678",
        "first_name": "John",
        "last_name": "Doe",
        "email": "john.doe@example.com"
      },
      "subscription": {
        "id": "sub-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
      },
      "membership_plan": {
        "id": "plan-22222222-3333-4444-5555-666666666666",
        "name": "3-Month Package"
      }
    }
  }
]
```

***

**Subscription Past Due Events**

```
GET /api/zapier/gym/membership/subscription-past-due-events
```

Returns recent subscription past due events (failed payments).

| Parameter | Type    | Default | Description             |
| --------- | ------- | ------- | ----------------------- |
| page      | integer | 0       | Page number (0-indexed) |

**CURL Example:**

```bash
curl -X GET "https://admin.btwb.com/api/zapier/gym/membership/subscription-past-due-events?page=0" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

**Response:**

```json
[
  {
    "id": "b8c9d0e1-f2a3-4567-hijk-890123456789",
    "time": "2024-01-22T06:00:00Z",
    "data": {
      "organization_id": "00000000-0000-0002-0000-00000001a2b3",
      "client": {
        "id": "c1d2e3f4-a5b6-7890-cdef-123456789012",
        "member_id": "m1n2o3p4-q5r6-7890-stuv-wxyz12345678",
        "first_name": "John",
        "last_name": "Doe",
        "email": "john.doe@example.com"
      },
      "subscription": {
        "id": "sub-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
      },
      "membership_plan": {
        "id": "plan-11111111-2222-3333-4444-555555555555",
        "name": "Unlimited Monthly"
      }
    }
  }
]
```

***

**Subscription Pause Started Events**

```
GET /api/zapier/gym/membership/subscription-pause-started-events
```

Returns recent subscription pause events.

| Parameter | Type    | Default | Description             |
| --------- | ------- | ------- | ----------------------- |
| page      | integer | 0       | Page number (0-indexed) |

**CURL Example:**

```bash
curl -X GET "https://admin.btwb.com/api/zapier/gym/membership/subscription-pause-started-events?page=0" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

**Response:**

```json
[
  {
    "id": "c9d0e1f2-a3b4-5678-ijkl-901234567890",
    "time": "2024-01-23T11:00:00Z",
    "data": {
      "organization_id": "00000000-0000-0002-0000-00000001a2b3",
      "client": {
        "id": "c1d2e3f4-a5b6-7890-cdef-123456789012",
        "member_id": "m1n2o3p4-q5r6-7890-stuv-wxyz12345678",
        "first_name": "John",
        "last_name": "Doe",
        "email": "john.doe@example.com"
      },
      "subscription": {
        "id": "sub-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
      },
      "membership_plan": {
        "id": "plan-11111111-2222-3333-4444-555555555555",
        "name": "Unlimited Monthly"
      }
    }
  }
]
```

***

**Subscription Pause Ended Events**

```
GET /api/zapier/gym/membership/subscription-pause-ended-events
```

Returns recent subscription resume events.

| Parameter | Type    | Default | Description             |
| --------- | ------- | ------- | ----------------------- |
| page      | integer | 0       | Page number (0-indexed) |

**CURL Example:**

```bash
curl -X GET "https://admin.btwb.com/api/zapier/gym/membership/subscription-pause-ended-events?page=0" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

**Response:**

```json
[
  {
    "id": "d0e1f2a3-b4c5-6789-jklm-012345678901",
    "time": "2024-02-01T00:00:00Z",
    "data": {
      "organization_id": "00000000-0000-0002-0000-00000001a2b3",
      "client": {
        "id": "c1d2e3f4-a5b6-7890-cdef-123456789012",
        "member_id": "m1n2o3p4-q5r6-7890-stuv-wxyz12345678",
        "first_name": "John",
        "last_name": "Doe",
        "email": "john.doe@example.com"
      },
      "subscription": {
        "id": "sub-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
      },
      "membership_plan": {
        "id": "plan-11111111-2222-3333-4444-555555555555",
        "name": "Unlimited Monthly"
      }
    }
  }
]
```

***

**Subscription Scheduled Events**

```
GET /api/zapier/gym/membership/subscription-scheduled-events
```

Returns recent subscription scheduling events (future start dates).

| Parameter | Type    | Default | Description             |
| --------- | ------- | ------- | ----------------------- |
| page      | integer | 0       | Page number (0-indexed) |

**CURL Example:**

```bash
curl -X GET "https://admin.btwb.com/api/zapier/gym/membership/subscription-scheduled-events?page=0" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

**Response:**

```json
[
  {
    "id": "e1f2a3b4-c5d6-7890-klmn-123456789012",
    "time": "2024-01-24T14:00:00Z",
    "data": {
      "organization_id": "00000000-0000-0002-0000-00000001a2b3",
      "client": {
        "id": "c1d2e3f4-a5b6-7890-cdef-123456789012",
        "member_id": "m1n2o3p4-q5r6-7890-stuv-wxyz12345678",
        "first_name": "John",
        "last_name": "Doe",
        "email": "john.doe@example.com"
      },
      "subscription": {
        "id": "sub-bbbbbbbb-cccc-dddd-eeee-ffffffffffff"
      },
      "membership_plan": {
        "id": "plan-11111111-2222-3333-4444-555555555555",
        "name": "Unlimited Monthly"
      }
    }
  }
]
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://btwb.gitbook.io/btwb/developers/api-reference.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
