# bsport API > REST API for partner integrations that act on behalf of a bsport company or franchise team: manage clients, schedule classes, book classes and appointments, read billing data and receive webhook events. Use V2 (`/api/v2/`) for new integrations. Owners and Admins create Public API keys in the Back Office, for a studio or a Master Account. Every page below is Markdown; replace `.md` with `.html` for the rendered page. ## Authentication Send these headers on every REST request: - `X-Api-Key`: the API key created in the Back Office. - `X-Client-ID`: the tool name entered when the API key was created. - `X-Company-ID` with a company API key, or `X-Franchisor-ID` with a franchise API key. A franchise API key can add `X-Company-ID` to act on one company of the franchise. Base URL: `https://public.production.bsport.io`. ## OpenAPI specs The OpenAPI files are the source of truth for endpoints, fields and filters. The V2 file is close to 1 MB: download it and attach it to your conversation rather than fetching it. - [V2 OpenAPI spec](https://api-docs.production.bsport.io/schemas/openapi-v2.yml) - [V2 webhook event catalogue](https://api-docs.production.bsport.io/schemas/webhooks-openapi-v2.yml) ## Changelog feed The [changelog RSS feed](https://api-docs.production.bsport.io/feed_rss_created.xml) lists every changelog entry, newest first, with the date it reached production. # Get started # Getting started bsport Public API is designed for partner integrations that act on behalf of your company or franchise team. Direct REST integrations use API keys that Owners and Admins create in the Back Office. Approved users can also connect compatible AI assistants through MCP and OAuth. These REST examples use V2. V1 remains a separate contract and retires on January 15, 2027; changing only the URL is not a migration strategy. See [Migrate from V1 to V2](https://api-docs.production.bsport.io/guides/11-migrate-from-v1-to-v2.html) and the [data model and terminology](https://api-docs.production.bsport.io/guides/08-terminology.html) and [Data model and terminology (V1)](https://api-docs.production.bsport.io/guides/v1/02-terminology.html). ## What you can do Use the API to automate operational workflows, such as managing clients, creating bookings, and querying billing information. All actions are performed in the context of a company or franchisor. ## Which version each surface uses Read the table by surface. The version decides which field names and IDs you receive. | Surface | Version | What it means for you | | ---------------- | --------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | REST API | V2 for new integrations. V1 is available until January 15, 2027 | Use `/api/v2/`. See [V2 workflows and field conventions](https://api-docs.production.bsport.io/guides/10-v2-workflows.html) | | Webhook payloads | V2 for new registrations. Existing registrations stay on V1 | New registrations use V2 event names and `data` follows the V2 response. See [Webhook event payloads](https://api-docs.production.bsport.io/webhooks/05-event-payloads.html) | | MCP | V2 | Tools expose V2 management operations. See the [MCP overview](https://api-docs.production.bsport.io/guides/mcp.html) | ## Prerequisites For a direct REST integration, you need: - An API key created in the Back Office (see below). - Your `X-Client-ID` value (used for tracing and support). - The company or franchisor identifier you will operate on. - The base URL (see below). Getting your API key and identifiers An Owner or Admin creates the key in the Back Office, on a plan that includes API keys: - For a studio: **Settings**, then **Webhooks & APIs**, then the **API** tab. - For a Master Account: **API keys** in the Master Account menu. The tool name entered when creating the key is your `X-Client-ID`. The key is shown only once: **Copy headers** copies it with your `X-Client-ID` and your `X-Company-ID` or `X-Franchisor-ID`. For an MCP connection, you need: - A bsport user account with MCP access. - The identifier of a company that user can access. - A compatible AI client. MCP uses OAuth and does not require a Public API key or `X-Client-ID`. See [Connect an AI assistant with MCP](https://api-docs.production.bsport.io/guides/09-connect-ai-assistants-with-mcp.html) for the production URL and client-specific instructions. ## Base URL Every endpoint path in this documentation is relative to `https://public.production.bsport.io`. Code samples use `YOUR_ENV_DOMAIN` as a placeholder: replace it with `public.production.bsport.io`. An API key acts on your live data with full admin access. Start with read requests, and create one key per integration so you can revoke one without stopping the others. ## First REST request Start with a ping request to verify connectivity and headers. ```bash curl -X GET \ -H 'X-Api-Key: YOUR_API_KEY' \ -H 'X-Client-ID: YOUR_CLIENT_ID' \ -H 'X-Company-ID: YOUR_COMPANY_ID' \ 'https://YOUR_ENV_DOMAIN/api/v2/monitoring/health/ping/' ``` Replace `YOUR_ENV_DOMAIN` with `public.production.bsport.io`. If the request succeeds, your REST integration is ready to use the guides and API reference. ## Next steps Follow the guides in this order. 1. [Authentication](https://api-docs.production.bsport.io/guides/01-authentication.html) and [Headers and tenant context](https://api-docs.production.bsport.io/guides/01-authentication.html#tenant-and-client-headers) 1. [Data model and terminology](https://api-docs.production.bsport.io/guides/08-terminology.html): the objects and how they relate 1. [Pagination and filtering](https://api-docs.production.bsport.io/guides/03-pagination-and-filtering.html), [Errors and status codes](https://api-docs.production.bsport.io/guides/04-errors-and-statuses.html) and [Rate limits and bulk data sync](https://api-docs.production.bsport.io/guides/06-rate-limits.html) 1. [V2 workflows and field conventions](https://api-docs.production.bsport.io/guides/10-v2-workflows.html): task guides 1. [Webhook event payloads](https://api-docs.production.bsport.io/webhooks/05-event-payloads.html) and the [Webhooks overview](https://api-docs.production.bsport.io/webhooks/00-index.html) 1. [Connect an AI assistant with MCP](https://api-docs.production.bsport.io/guides/09-connect-ai-assistants-with-mcp.html) and [Using LLMs for custom integrations](https://api-docs.production.bsport.io/guides/05-using-llms-for-integrations.html) 1. Coming from V1: [Migrate from V1 to V2](https://api-docs.production.bsport.io/guides/11-migrate-from-v1-to-v2.html) Ask an AI assistant about these docs [llms.txt](/llms.txt) lists these guides, the OpenAPI files and the changelog in the [llms.txt format](https://llmstxt.org), a plain-text index written for AI assistants. Each guide also has a Markdown version: replace `.html` with `.md` in its URL. If your assistant can fetch web pages, give it the `llms.txt` URL and ask your question. # Authentication and headers Direct REST integrations use API key authentication. Owners and Admins create keys in the Back Office: see [Getting started](https://api-docs.production.bsport.io/guides/00-getting-started.html#prerequisites). Connections from compatible AI assistants use OAuth instead of an API key. See [Connect an AI assistant with MCP](https://api-docs.production.bsport.io/guides/09-connect-ai-assistants-with-mcp.html). The remainder of this page applies only to direct REST integrations. Keep your API key secure Treat your API key like a password. Store it server-side, revoke it in the Back Office if it is exposed, and never embed it in client-side code. ## REST API key header Send your API key in the `X-Api-Key` header on every request. ```bash curl -X GET \ -H 'X-Api-Key: YOUR_API_KEY' \ -H 'X-Client-ID: YOUR_CLIENT_ID' \ -H 'X-Company-ID: YOUR_COMPANY_ID' \ 'https://YOUR_ENV_DOMAIN/api/v2/management/clients/' ``` Replace `YOUR_ENV_DOMAIN` with `public.production.bsport.io`. ## Tenant and client headers Every request must include headers that identify the calling client and the tenant (company or franchisor) you are operating on. ### Required headers - `X-Api-Key`: authenticates the request. - `X-Client-ID`: the tool name entered when the API key was created. - `X-Company-ID` or `X-Franchisor-ID`: sets the tenant context. ### Tenant context rules - Company API keys must include `X-Company-ID`. - Franchise API keys must include `X-Franchisor-ID`. - Franchise API keys can optionally include `X-Company-ID` to act on behalf of a specific company within that franchise. ```text X-Api-Key: YOUR_API_KEY X-Client-ID: YOUR_CLIENT_ID X-Company-ID: YOUR_COMPANY_ID ``` ```text X-Api-Key: YOUR_API_KEY X-Client-ID: YOUR_CLIENT_ID X-Franchisor-ID: YOUR_FRANCHISOR_ID X-Company-ID: TARGET_COMPANY_ID ``` ### Optional headers - `X-Timezone-Name`: replaces the target company's time zone for a V2 `GET` request. See [Dates, time zones and amounts](https://api-docs.production.bsport.io/guides/12-dates-time-zones-and-amounts.html). ```text X-Timezone-Name: Europe/Paris ``` `X-Client-ID` must match the key Send the tool name entered when the API key was created. Any other value returns `401`. ## Check your API key and usage Send `GET /api/v2/monitoring/me/` with your usual headers to see which key you are using and how many calls were made on its company or franchise. The response gives the key's `client_id`, its company or franchise, `expires_at`, and the successful calls (`2xx` or `3xx`) of the last 12 UTC calendar months, current month first. Counts cover the whole company or franchise, not one key. A month without calls shows `0`. The current month is live. Earlier months are copied once a day, at 02:15 Paris time: until that copy on the 1st, the previous month misses up to its last day of calls. What the counts cover depends on the key: | Key | `monthly_usage` | `companies` | | ----------------- | ------------------------------------------ | --------------------------------------------------------- | | Company API key | Every call made on your company | Empty | | Franchise API key | Every call made with your franchise's keys | Each company of the franchise, with every call made on it | Company counts include franchise-key calls only from the release that added this endpoint, so earlier months of a franchise company show fewer calls. See the [Changelog](https://api-docs.production.bsport.io/changelog/index.html). `X-Company-ID` does not change the answer for a franchise key. This call counts like any other and follows the default [rate limits](https://api-docs.production.bsport.io/guides/06-rate-limits.html). ## REST API key troubleshooting If you receive a `401` or `403`, confirm that your API key is valid and that you are sending the required tenant headers. See [Tenant and client headers](#tenant-and-client-headers) for details. # Concepts # Data model and terminology This page explains the names the V2 REST API uses for resources and fields, and how they relate to the names in the Back Office. Use it to pick the right resource and field names when you build against V2. - For V1 names, see [Data model and terminology (V1)](https://api-docs.production.bsport.io/guides/v1/02-terminology.html). - For webhook event names such as `class.updated`, and the historical V1 names such as `offer-update` and `member-create`, see [Event names and historical terms](https://api-docs.production.bsport.io/webhooks/05-event-payloads.html#event-names-and-historical-terms). ## Company and venue A company is the business whose data you access through the Public API or MCP. A venue is a physical place associated with one or more companies. Use the company identifier for company scope and the venue identifier when selecting a physical place. `venue` is the resource name in the Public API and the Back Office. Older surfaces call the same place an `establishment`. Do not confuse it with a Back Office location, which is a group of venues billed as one entity. ## Client `client` is the V2 resource name (`/clients/`). In the Back Office, "client" is the umbrella term for leads, customers and members. `consumer`, `customer`, and `user` describe the platform-wide account in older surfaces. They are not client identifiers and must not be used to call `/clients/{id}/`. ## Class, appointment, and service Read the table by term. It shows what each term is and where it appears in V2. | Term | What it is | Where it appears | | --------------------- | --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | | `class` | A group fitness session with a fixed schedule and capacity. | `/classes/` endpoint | | `appointment` | A private 1-on-1 session booked by one client with one teacher. | `/appointments/` endpoint | | `service` | The offering above the class instance, for example "Yoga" or "Personal Training". A single service can have many class instances. | `/services/` endpoint, `service_id` on `/classes/` | | `appointment service` | The template behind private sessions. | `/appointment-services/` endpoint, `appointment_service_id` on `/appointments/` | Bookings use `class_id` and `class_ids` for the related class. V2 has no separate session resource. Using a booking class identifier to fetch class details Use `class_id` directly with `GET /api/v2/management/classes/{class_id}/`. V2 booking filters accept only service IDs, through `?service_ids=`. ### Appointments, appointment services, and appointment slots Three resources describe a private session. The diagram of how they point to each other is in [How appointments, services and slots relate](https://api-docs.production.bsport.io/guides/tasks/book-classes-and-appointments.html#how-appointments-services-and-slots-relate). Read the table by resource. | Resource | What it is | Key fields | | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------- | | Appointment service | The private-session offering a client books, for example a massage. | `name`, `description`, `appointment_slot_ids` | | Appointment slot | One duration and credit-price option of a service. A service can have several slots, for example 30 minutes for 1 credit and 60 minutes for 2 credits. | `appointment_service_id`, `duration_in_minutes`, `credit_price`, `is_active` | | Appointment | One private session booked by one client on one slot, starting at a chosen time. | `appointment_service_id`, `appointment_slot_id`, `client_id`, `teacher_id`, `venue_id`, `starts_at`, `credit_price` | A slot describes a duration and a credit cost, not a time on the calendar. Listing appointments returns existing bookings, and V2 has no availability search: you choose the `starts_at` when you book. To book, pick a slot from the service's `appointment_slot_ids`, then follow [Book an appointment](https://api-docs.production.bsport.io/guides/tasks/book-classes-and-appointments.html#book-an-appointment). Add `expand[]=appointment_slot_id` or `expand[]=appointment_service_id` to replace the ID with the full object. `appointment_service_id` replaces the V1 `service_id` on appointments. ## Teacher V2 exposes the company-scoped instructor record under the term `teacher`. | Term | What it is | Where it appears | | --------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | | `teacher` | An instructor associated with a specific studio. | `/teachers/` endpoint, and `teacher_id` fields and filters on `/classes/`, `/appointments/` and `/bookings/` | | `coach` | The platform-level instructor account shared across studios. | Legacy Back Office surfaces and V1. V2 uses teacher IDs instead | V2 teacher IDs are always company-scoped IDs returned by the Teachers endpoint. Never reuse an ID from V1 without checking the [migration guide](https://api-docs.production.bsport.io/guides/11-migrate-from-v1-to-v2.html#service-and-teacher-ids). ## Class passes, appointment passes, and subscriptions A class pass grants access to group classes, while an appointment pass grants access to private appointments. "Passes" is the Back Office term for both types. The table shows the resource for each product and for the product owned by a client. | Product | Product owned by a client | | ------------------ | ------------------------- | | `class_pass` | `client_class_pass` | | `appointment_pass` | `client_appointment_pass` | | `subscription` | `client_subscription` | A `subscription` is a subscription product, and a `client_subscription` is an active subscription owned by a client. The Back Office calls a subscription a membership. For how a pass reaches a booking or an appointment, see [Which pass pays for a booking](https://api-docs.production.bsport.io/guides/tasks/book-classes-and-appointments.html#which-pass-pays-for-a-booking). ## Other objects added in V2 These objects have no V1 equivalent. Read the table by object. The endpoints are under `/api/v2/management/`. | Object | Endpoint | What it is | | ------------------- | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Level | `/levels/` | The difficulty level a class can carry, sent as `level_id` when you create or update a class. It lists your company's levels and the levels shared across companies. Retired levels stay listed with `is_active` set to `false`. | | Discount code | `/coupons/` | A code that takes money off a one-off purchase. `type` is `standard` or `unique_codes`, and `applies_to` sets the scope: all purchases, class passes, products, delivery fees, appointment passes or bundles. The API calls it a coupon. | | Discount code usage | `/coupon-usages/` | One record each time a discount code is applied to a purchase. It links the code (`coupon_id`), the client (`client_id`) and the invoice (`invoice_id`), and `is_reverted` shows whether the discount was reversed. Read only. | | Gift card | `/gift-cards/` | A prepaid value a client can buy and spend. `type` is `fixed_amount` or `flexible_amount`, and flexible cards have a minimum and a maximum amount. | | Product | `/products/` | A retail product sold by the studio. `type` is `standalone`, `base` or `variant`. A base product groups variants, and each variant points to its base through `base_product_id` and differs by `color` or `size`. | | Invoice | `/invoices/` | The commercial document for a purchase. It has a status (`draft`, `open`, `paid`, `voided` or `refunded`), its amounts and its `line_items`. | | Invoice item | `/invoice-items/` | One line of an invoice, linked by `invoice_id`. It shows the original, discount and total amounts, and whether the line is refunded. | | Teacher pay rate | `/teacher-pay-rates/` | A rule for how a teacher is paid. `applies_to` is `class`, `appointment`, `group_class` or `workshop`, with base, minimum and maximum amounts and bonuses. You assign it from `/teachers/{id}/pay-rates/`. | | Communication | `/communications/` | An email or SMS queued through the API, with a processing `status` of `queued`, `processed`, `failed` or `unknown`. It does not list messages sent from the Back Office or automations. | For how a purchase, its invoice and a discount code connect, see [How invoices, items and discount codes connect](https://api-docs.production.bsport.io/guides/tasks/read-billing-data.html#how-invoices-items-and-discount-codes-connect). For amount units, filters and side effects, see [V2 workflows and field conventions](https://api-docs.production.bsport.io/guides/10-v2-workflows.html). ## Find the ID you need Use IDs returned by the V2 resource you are referencing. A client ID identifies a client of the company, and a teacher ID identifies a teacher associated with that company. Do not substitute platform account IDs or V1 teacher IDs. The following relationships have different discovery paths. | Required value | Where to obtain it | | --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `class_id`, `class_ids` | `/api/v2/management/classes/` | | `client_class_pass_id` | `/api/v2/management/client-class-passes/?client_ids=123` | | Appointment `appointment_slot_id` | `appointment_slot_ids` on an appointment service, then `/api/v2/management/appointment-slots/{id}/` | | `teacher_id`, `venue_id`, `level_id` | `/teachers/`, `/venues/`, `/levels/` under `/api/v2/management/` | | Product `base_product_id` | `/api/v2/management/products/?type=base` | | Category identifiers | Existing catalogue records expose category IDs, but V2 has no category directory endpoint. Obtain any additional category IDs from the company's configuration. | | Subscription benefit with `benefit_type=pack` | V2 exposes its identifier but has no pack detail endpoint. | | Subscription `pause_ids` | V2 exposes these identifiers but has no pause detail endpoint. | `GET /clients/` already scopes results to `X-Company-ID`. Its `company_id` query filter only narrows those results; it does not switch companies. Omit it for the normal case. IDs represent whole-number identifiers even where a query parameter is described as a number. # Pagination and filtering The examples in this guide use V2. For V1, see [Pagination and filtering (V1)](https://api-docs.production.bsport.io/guides/v1/01-pagination-and-filtering.html). List endpoints return paginated results. Use pagination to control result size and filtering to narrow the dataset to what your integration needs. ## Pagination Most list endpoints accept: - `page`: the page number to return. Defaults to `1`. - `page_size`: how many results per page. Defaults to `50`, maximum `100`. ```bash curl -X GET \ -H 'X-Api-Key: YOUR_API_KEY' \ -H 'X-Client-ID: YOUR_CLIENT_ID' \ -H 'X-Company-ID: YOUR_COMPANY_ID' \ 'https://YOUR_ENV_DOMAIN/api/v2/management/clients/?page=2&page_size=50' ``` Replace `YOUR_ENV_DOMAIN` with `public.production.bsport.io`. ### Response shape A paginated response wraps the records in an envelope: ```json { "count": 253, "next": "https://YOUR_ENV_DOMAIN/api/v2/management/clients/?page=3&page_size=50", "next_page": 3, "previous": "https://YOUR_ENV_DOMAIN/api/v2/management/clients/?page=1&page_size=50", "results": [] } ``` | Field | Meaning | | ----------- | --------------------------------------------------------------- | | `count` | Total number of records matching the request, across all pages. | | `next` | Full URL of the next page, or `null` on the last page. | | `next_page` | Page number of the next page, or `null` on the last page. | | `previous` | Full URL of the previous page, or `null` on the first page. | | `results` | The records for the current page. | ### Paginate through every page Stop when `next_page` is `null`. Prefer this over comparing the length of `results` against `page_size`: the envelope states the end of the collection directly, so your loop does not depend on a full final page. ```python def fetch_all(path, params=None): results = [] page = 1 while page is not None: response = requests.get( f"{BASE_URL}{path}", headers=HEADERS, params={**(params or {}), "page": page, "page_size": 100}, ) response.raise_for_status() body = response.json() results.extend(body["results"]) page = body["next_page"] return results ``` Tune page size for performance Start with a moderate `page_size` (25-100) and adjust based on latency and the amount of data you need to process. ## Ordering Use the `ordering` parameter to sort results. Prefix a field with `-` (dash) for descending order, and separate several fields with commas to sort on more than one key. ```text ordering=joined_date ordering=-joined_date ordering=lastname,-joined_date ``` Ordering is available on a defined set of list endpoints, and each one accepts its own list of sortable fields: | Endpoint | Sortable fields | | ----------------------------------------------- | ---------------------------------------------------------------------------- | | `/api/v2/management/clients/` | `client_account_balance`, `email`, `fullname`, `joined_date`, `lastname` | | `/api/v2/management/bookings/` | `created_at`, `class_start_at` | | `/api/v2/management/client-class-passes/` | `available_credits_amount`, `purchased_date`, `starting_date`, `ending_date` | | `/api/v2/management/client-subscriptions/` | `created_at`, `first_billing_date`, `name`, `recurrent_price` | | `/api/v2/management/class-passes/` | `name`, `price` | | `/api/v2/management/subscriptions/` | `name`, `recurrent_price` | | `/api/v2/management/client-notes/` | `creation_date`, `id` | | `/api/v2/management/tags/` | `tag_group_id`, `id` | | `/api/v2/management/tag-groups/` | `id`, `name` | | `/api/v2/management/appointment-passes/` | `name`, `price` | | `/api/v2/management/client-appointment-passes/` | `available_credits_amount`, `purchased_at` | | `/api/v2/management/coupons/` | `created_at`, `expiration_date`, `name` | | `/api/v2/management/coupon-usages/` | `discount_amount`, `used_at` | | `/api/v2/management/gift-cards/` | `fixed_amount`, `name`, `validity_days` | | `/api/v2/management/invoices/` | `created_at`, `issued_at`, `total_amount` | | `/api/v2/management/invoice-items/` | `id`, `total_amount` | Each endpoint's API Reference entry lists the same set, and is authoritative if the two ever differ. Unsupported ordering fields are ignored, not rejected A field that an endpoint does not support is discarded rather than returning an error. The request succeeds with `200` and the results come back in the endpoint's default order. A misspelled field name therefore fails silently: check the sort order of the response when you first wire up `ordering`. ## Filtering Filters are exposed as query parameters on each endpoint. Common patterns include: - `*_ids` for multiple IDs (comma-separated, e.g. `client_ids=123,456`); an empty list such as `client_ids=` returns `400` - `*_after` and `*_before` on a timestamp field (e.g. `created_after` for `created_at`) - `*_after_date` and `*_before_date` on a date field (e.g. `joined_after_date` for `joined_date`) See [Date and timestamp filters](#date-and-timestamp-filters). ### Default filters Some endpoints apply a default filter when you omit the parameter, so an unfiltered request does not always return the complete dataset. `GET /api/v2/management/classes/` and `/api/v2/management/appointments/` filter on the start datetime through `starts_after` and `starts_before` (ISO 8601). Each one applies its own default when omitted: | Parameter | Omitted value | | --------------- | ------------- | | `starts_after` | now | | `starts_before` | now + 30 days | A request to `/classes/` with no parameters therefore returns only the next 30 days of classes. Pass `starts_after` explicitly to read classes that have already taken place, and `starts_before` to read further ahead. ```bash curl -X GET \ -H 'X-Api-Key: YOUR_API_KEY' \ -H 'X-Client-ID: YOUR_CLIENT_ID' \ -H 'X-Company-ID: YOUR_COMPANY_ID' \ 'https://YOUR_ENV_DOMAIN/api/v2/management/classes/?starts_after=2026-01-01&starts_before=2026-03-31T23:59:59.999999' ``` ### Date and timestamp filters Two filter families take different formats. Read the table to pick the format for the parameter you send. | Filter family | Format | Where it applies | | ------------------------------- | -------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `*_after_date`, `*_before_date` | Date only, `YYYY-MM-DD`. Do not send a timestamp. | `clients` (`joined_*`), `client-class-passes` (`purchased_*`) | | `*_after`, `*_before` | ISO 8601 timestamp, preferably with its UTC offset | `bookings` (`created_*`, `class_start_*`), `client-appointment-passes` (`purchased_*`), `invoices` (`created_*`, `issued_*`), `invoice-items` (`invoice_issued_*`), `coupon-usages` (`used_*`), `classes` and `appointments` (`starts_*`) | Both bounds are inclusive. A timestamp without an offset is read in the company's time zone, or in the time zone `X-Timezone-Name` names when you send it, and so is a plain date sent to a timestamp filter: `created_before=2026-03-11` means midnight at the start of March 11, 2026, so it leaves that day out. See [Dates, time zones and amounts](https://api-docs.production.bsport.io/guides/12-dates-time-zones-and-amounts.html). ### Filtering example Combine filters as query parameters on the same request. ```bash curl -X GET \ -H 'X-Api-Key: YOUR_API_KEY' \ -H 'X-Client-ID: YOUR_CLIENT_ID' \ -H 'X-Company-ID: YOUR_COMPANY_ID' \ 'https://YOUR_ENV_DOMAIN/api/v2/management/bookings/?client_id=123&class_start_after=2025-01-01' ``` Validate filters per endpoint The filter set differs per endpoint. Names follow the patterns above, and the date format depends on the filter family. Check the API reference for the endpoint before adding a filter to your integration: a query parameter the endpoint does not support, or a value a filter cannot read, is refused with `400` and code `BSPORT-400`. See [Query parameter errors](https://api-docs.production.bsport.io/guides/04-errors-and-statuses.html#query-parameter-errors). ## Expanding related resources Supported Management `GET` list and detail endpoints can replace selected related-resource IDs with their complete objects. Repeat `expand[]` for multiple fields and use dot notation for nested relationships, up to two levels. ```bash curl -X GET \ -H 'X-Api-Key: YOUR_API_KEY' \ -H 'X-Client-ID: YOUR_CLIENT_ID' \ -H 'X-Company-ID: YOUR_COMPANY_ID' \ 'https://YOUR_ENV_DOMAIN/api/v2/management/bookings/?expand[]=client_id&expand[]=class_id.teacher_id' ``` Without expansion, `class_id` is an integer. With `expand[]=class_id`, the same `class_id` field contains the class object. An unsupported field or a path deeper than two levels returns `400 Bad Request`. Each endpoint's API Reference lists its supported expansion paths. An absent relationship remains `null`; an unresolved related resource keeps its scalar ID. # Errors and status codes The Public API follows standard HTTP status codes and documents the error body for each operation. Authentication failures can have an empty body. Use the status code to drive your retry and fallback logic. ## Common status codes - `200` / `201`: request successful. - `400`: request is invalid (missing or malformed input, or a V2 query parameter that is unknown or has an invalid value: see [Query parameter errors](#query-parameter-errors)). - `401`: authentication error: an invalid, expired or revoked API key (the JWT sent in `X-Api-Key`), or a missing client or tenant header. A rejected API key returns an empty body and a `WWW-Authenticate: ApiKey` header. - `403`: authorization error (no API key sent, or not allowed for the current tenant context). - `404`: resource or requested page not found. - `409`: the request conflicts with the current resource state or company configuration. - `429`: rate limit exceeded (retry later). - `500`: unexpected server error. ## Error response shape Error bodies depend on the failure source. Most JSON errors include a `detail` field describing what went wrong. Domain errors and rate-limit responses also include a stable `code`; validation and permission errors may instead include a `status` field or field-specific validation messages. Authentication can also return an empty body. The API Reference documents the possible bodies for each operation and status. ```json { "detail": "Rate limit exceeded", "code": "BSPORT-429" } ``` A list request for a page that does not exist returns `404` with `detail` and a `status` field. A V2 query parameter that is unknown or has an invalid value returns `400` with code `BSPORT-400`: see [Query parameter errors](#query-parameter-errors). Shared infrastructure codes use the `BSPORT-` pattern, for example `BSPORT-400` for an unknown or invalid V2 query parameter, `BSPORT-429` for a rate-limit rejection and `BSPORT-500` for an unexpected server error. Domain errors use exactly three uppercase letters followed by a hyphen and three digits, such as `CLI-001`, `CAP-103`, or `ASV-001`. When a response includes `code`, match on it rather than parsing `detail`: the message wording can change, while the documented code identifies the error. Include the error code in support tickets If you contact support, include the `code` value when present, the full response payload and the timestamp of the request to help us trace logs quickly. ## Query parameter errors A V2 request returns `400` with code `BSPORT-400` when a query parameter is unknown to the operation or has a value its filter cannot read. One response lists every problem. For example, `GET /api/v2/management/invoices/?created_after_date=2026-10-01&status=bogus` returns: ```json { "detail": "Unknown query parameters: created_after_date (did you mean created_after?). Invalid query parameter values: status.", "code": "BSPORT-400", "status": 400, "invalid_params": [ {"name": "created_after_date", "reason": "unknown", "suggestion": "created_after"}, {"name": "status", "reason": "invalid_value", "message": "Select a valid choice. bogus is not one of the available choices."} ], "doc_url": "https://api-docs.production.bsport.io/guides/04-errors-and-statuses.html#query-parameter-errors" } ``` Each `invalid_params` entry has these fields: | Field | Meaning | | ------------ | -------------------------------------------------------------------------------------------------------------------- | | `name` | The query parameter as you sent it. | | `reason` | `unknown`: the operation does not read this parameter. `invalid_value`: the filter exists but cannot read the value. | | `suggestion` | For `unknown`, the closest parameter the operation supports, when one is close enough. | | `message` | For `invalid_value`, why the value was refused. | Rename or remove the parameter before retrying, and check the operation's parameters in the API Reference. An unsupported `ordering` field is still ignored. ## Retries - Retry `429` responses after the rate limit window. See [Rate limits and bulk data sync](https://api-docs.production.bsport.io/guides/06-rate-limits.html) for the exact wait. - Do not retry `400` or `403` without changing the request. - Retry failed reads with bounded backoff. For writes, a `500`, timeout or lost response does not prove that no change occurred. Read the affected resource before deciding whether to retry. Communication sends cannot be conclusively matched after a lost response and must not be automatically resent. - For a configuration conflict, correct the company or resource configuration before retrying. Gift-card and product financial setup is not editable through this API; arrange that setup with the company in Back Office. No Retry-After header is returned A `429` response carries the standard error body and no `Retry-After` header. Wait for the documented rate limit window rather than reading a header value. # Rate limits and bulk data sync The Public API enforces rate limits to protect platform stability. This guide covers the limits, how to handle them, and how to structure an initial bulk import safely. ## Limits Read the table by scope. | Scope | Limit | | ------------------------------------------------------------------------------------------------------------------------- | ------------- | | Default requests per second, per tenant, per endpoint, per HTTP method | 20 | | `POST /api/v2/management/communications/`, per company and franchise context | 10 per minute | | `POST /api/v2/management/webhook-registrations/{id}/test/`, per company and franchise context, all registrations together | 5 per minute | | Maximum `page_size` on list endpoints | 100 | Each counter is scoped to one combination of HTTP method, endpoint and tenant. `GET` and `POST` on the same endpoint therefore use separate counters, and two different endpoints never share one. For a franchise integration, the tenant is the franchisor and company pair, so each company you operate on carries its own counter. When the rate limit is exceeded, the API returns `429 Too Many Requests`. ## Handling 429 responses A rejected request returns `429` with the standard error body: ```json { "detail": "Rate limit exceeded", "code": "BSPORT-429" } ``` **No `Retry-After` header is returned.** Base your wait on the window below rather than looking for a header. The default counter is a fixed 1-second window: it starts on your first request in that window and resets 1 second later, rather than sliding with each call. In practice: 1. Wait 1 second after a default-limit `429`. For communication sends and webhook tests, wait 60 seconds. Retry only after a definite rejection; a lost response must not trigger an automatic resend. 1. If the retry is also rejected, apply exponential backoff (2 s, 4 s, 8 s) and lower your sustained request rate: repeated rejections mean the calling pattern is above the limit, not that a single burst was unlucky. 1. Do not retry immediately, and do not retry in a tight loop. See [Errors and status codes](https://api-docs.production.bsport.io/guides/04-errors-and-statuses.html) for general retry guidance. ## Initial data sync (bulk import) Use exports for large bulk syncs The Public API is not recommended for full historical exports or large bulk data syncs. Use report exports when available, or contact your account manager to request an export. The example below is only for limited initial syncs where using the Public API is necessary. Pulling your full dataset for the first time is the highest-risk moment for rate limit violations. A high-frequency full scan can exhaust the limit quickly and cause `429` errors or timeouts on large datasets. Recommended pattern: 1. Break the import into date-range windows (one month at a time is a safe default). 1. Use the maximum `page_size` of 100 to minimize the number of requests. 1. Add a pause between requests (300 ms minimum; 300-500 ms recommended) to stay within the per-second limit. 1. Do not repeat a full scan after the initial import. Switch to incremental sync or webhooks for ongoing updates. ```bash # Example: paginate one month at a time to limit the result set curl -X GET \ -H 'X-Api-Key: YOUR_API_KEY' \ -H 'X-Client-ID: YOUR_CLIENT_ID' \ -H 'X-Company-ID: YOUR_COMPANY_ID' \ 'https://YOUR_ENV_DOMAIN/api/v2/management/clients/?page_size=100&page=1&joined_after_date=2025-01-31' ``` Replace `YOUR_ENV_DOMAIN` with `public.production.bsport.io`. Increment `page` until `next_page` is `null`: that signals the last page. See [Pagination and filtering](https://api-docs.production.bsport.io/guides/03-pagination-and-filtering.html) for the response envelope and a reusable pagination loop. ## Ongoing sync after the initial import Once the initial import is complete, avoid rescanning the full dataset on each run. Preferred approaches: - **Webhooks**: create a V2 registration for a supported Public API event such as `client.created`, `booking.created` or `class.updated` to receive updates in near real time. See the [event catalogue](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html). - **Incremental polling**: use the endpoint's documented query parameters, such as `created_after` for bookings and invoices. Response field names such as `created_at` are not necessarily accepted as query parameters. - **Targeted lookups**: when you only need to refresh a specific client or booking, fetch by ID rather than re-listing. ## `client-class-passes` endpoint at scale Filter this endpoint to avoid timeouts `GET /api/v2/management/client-class-passes/` can return `502` or `504` for companies holding a large number of passes, because an unfiltered result set is expensive to build. The request fails rather than returning partial data, so your integration sees a timeout instead of an incomplete page. Always send a narrow filter such as `client_ids` or a date range. Do not scan this endpoint unfiltered, particularly during an initial import. # Task guides # V2 workflows and field conventions Use these guides to connect the resources in the [V2 reference](https://api-docs.production.bsport.io/reference/01-scalar-v2.html) and to understand the effects of write requests. They cover management integrations that use company credentials. They do not provide a client-facing booking or checkout API. For authentication, start with [Getting started](https://api-docs.production.bsport.io/guides/00-getting-started.html). If you are moving from V1, read [Migrate from V1 to V2](https://api-docs.production.bsport.io/guides/11-migrate-from-v1-to-v2.html) first. Read the table by task. Each row links to the guide and names the main endpoints. | Task | Guide | Main endpoints | | --------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | | Book classes, cancel a booking, book an appointment | [Book classes and appointments](https://api-docs.production.bsport.io/guides/tasks/book-classes-and-appointments.html) | `/bookings/`, `/appointments/` | | Schedule, update and cancel classes | [Schedule and cancel classes](https://api-docs.production.bsport.io/guides/tasks/schedule-and-cancel-classes.html) | `/classes/` | | Email or SMS clients | [Send an email or SMS](https://api-docs.production.bsport.io/guides/tasks/send-an-email-or-sms.html) | `/communications/` | | Read invoices and invoice items | [Read billing data](https://api-docs.production.bsport.io/guides/tasks/read-billing-data.html) | `/invoices/`, `/invoice-items/` | | Create gift cards and retail products | [Create catalogue items](https://api-docs.production.bsport.io/guides/tasks/create-catalogue-items.html) | `/gift-cards/`, `/products/`, `/coupons/` | | Update clients, notes, tags and tag groups | [Manage clients, notes and tags](https://api-docs.production.bsport.io/guides/tasks/manage-clients-notes-and-tags.html) | `/clients/`, `/client-notes/`, `/tags/`, `/tag-groups/` | | Assign teacher pay rates | [Assign teacher pay rates](https://api-docs.production.bsport.io/guides/tasks/assign-teacher-pay-rates.html) | `/teachers/{id}/pay-rates/` | | Know what a write changes | [Understand updates and disabling](https://api-docs.production.bsport.io/guides/tasks/understand-updates-and-disabling.html) | PATCH, enable and disable actions | To find which ID goes in a field, see [Find the ID you need](https://api-docs.production.bsport.io/guides/08-terminology.html#find-the-id-you-need). # Assign teacher pay rates Use this guide to assign and update the pay rates of a teacher. `POST /teachers/{id}/pay-rates/` assigns initial pay rates to a teacher without a configuration. `PATCH /teachers/{id}/pay-rates/` updates an existing configuration. Read the result from `/teacher-pay-rates/`. Excluded class passes use `excluded_class_pass_ids`. Cancellation-related fields use American spelling: `canceled_amount`, `canceled_bookings_count_as_confirmed` and the `canceled_bookings` bonus applicability value. # Book classes and appointments Use this guide to book a client into classes and appointments, cancel a booking, and read a booking status. For how appointments, services and slots relate, see [Data model and terminology](https://api-docs.production.bsport.io/guides/08-terminology.html#appointments-appointment-services-and-appointment-slots). ## Book classes 1. Find the client and list their client class passes. 1. Find the classes and check their booking windows and available capacity. 1. For a class with assigned places, list `/classes/{id}/spots/` to obtain a `spot_id`. 1. Submit the client, pass and class identifiers to `/bookings/`. For example, this request books one class and lets bsport assign a place. Replace the example IDs with values returned for your company, and `YOUR_ENV_DOMAIN` with `public.production.bsport.io`. ```bash curl -X POST 'https://YOUR_ENV_DOMAIN/api/v2/management/bookings/' \ -H 'X-Api-Key: YOUR_API_KEY' \ -H 'X-Client-ID: YOUR_CLIENT_ID' \ -H 'X-Company-ID: YOUR_COMPANY_ID' \ -H 'Content-Type: application/json' \ -d '{"client_id":123,"client_class_pass_id":456,"class_ids":[789],"should_auto_assign_spot":true}' ``` A `201` response contains a `bookings` array. The same pass, `spot_id` and options apply to every entry in `class_ids`. Use separate requests when different classes need different places. A validation failure rolls back the requested bookings and credit changes; a failure after creation, including a lost response, does not prove that nothing was booked. Query the client's bookings before deciding to repeat a write. Booking list and detail responses include `company_id`, taken from the company that owns the class. Access checks use the same ownership, including for historical bookings. `should_keep_credits=true` creates the booking without deducting pass credits. The default is `false`. `should_notify_client` defaults to `true`. ### Cancel a booking `POST /bookings/{id}/cancel/` accepts an omitted body. For this manager operation, both options default to `false`: cancellation does not force a credit refund or send the cancellation notification. Set `should_force_refund=true` to refund consumed credits, and `should_force_notify=true` to request the cancellation notification. A credit refund is not a refund of the purchase price. ### Interpret booking status The response and query filter use different representations of the same status. | Response `booking_status_code` | Query `booking_status_code` | | ------------------------------ | --------------------------- | | `OK` | `0` | | `Canceled by manager` | `1` | | `Canceled by client` | `2` | | `Class canceled` | `3` | `spot_information` is display metadata, not the identifier to submit when booking. It can be empty or null. Its display fields include `name`, `shape`, `prefix`, `suffix`, `fill`, `stroke` and numeric `indexType`; use `spot_id` to select a place. ## Book an appointment A slot describes a duration and a credit cost, not a free time on the calendar, and V2 has no availability search. See [Appointments, appointment services, and appointment slots](https://api-docs.production.bsport.io/guides/08-terminology.html#appointments-appointment-services-and-appointment-slots) for how the three resources relate. Choose an `appointment_slot_id`, `client_id` and `starts_at`. An example request body is: ```json {"client_id":123,"appointment_slot_id":456,"starts_at":"2026-11-10T10:00:00+01:00"} ``` Submit it to `POST /api/v2/management/appointments/` with the same authentication and JSON headers as the class-booking example. If the service has several teachers or venues, supply the corresponding `teacher_id` or `venue_id`. The service response does not expose these associations; confirm the service configuration with the company before booking. A service with one eligible teacher or venue selects it automatically. The request cannot choose a client appointment pass. bsport selects the compatible pass with the earliest expiration date, then the lowest ID if expiration dates tie. No compatible pass or insufficient credits prevents creation. Use the returned appointment ID for subsequent reads or cancellation; cancellation refunds the booking credits. ### How appointments, services and slots relate Color and shape show what kind of resource a box is. Teal rectangles are set up by the studio, purple pills are held by a client, amber rounded boxes are records of something that happened, and the grey hexagon is the client. A solid arrow starts at the resource that holds an ID and ends at the resource the ID refers to. A dotted arrow is a relationship without an ID field. ``` %%{init: {"flowchart": {"curve": "basis", "nodeSpacing": 45, "rankSpacing": 60, "padding": 14}}}%% flowchart LR appointment("Appointment
/appointments/
One booking for one client") service["Appointment service
/appointment-services/
The offering"] slot["Appointment slot
/appointment-slots/
One duration and credit price"] appointment -->|"appointment_service_id"| service service -->|"appointment_slot_ids"| slot appointment -->|"appointment_slot_id"| slot class appointment record class service,slot definition classDef definition fill:#beede5,stroke:#21837d,stroke-width:2px,color:#0f3d39 classDef held fill:#ece4f8,stroke:#6b4fa3,stroke-width:2px,color:#35205f classDef record fill:#fef3c7,stroke:#d97706,stroke-width:2px,color:#5e2a0c classDef person fill:#e5eaea,stroke:#565e5d,stroke-width:2px,color:#1e2323 linkStyle default stroke-width:1.5px ``` ## Which pass pays for a booking A client pass holds the credits a client has left. The colors and arrows are the same as in the previous diagram. ``` %%{init: {"flowchart": {"curve": "basis", "nodeSpacing": 45, "rankSpacing": 60, "padding": 14}}}%% flowchart LR subgraph groupClasses ["Group classes"] direction LR classPass["
Class pass
/class-passes/
"] clientClassPass(["
Client class pass
/client-class-passes/
"]) booking("
Booking
/bookings/
") clientClassPass -->|"
class_pass_id
"| classPass booking -->|"
client_class_pass_id
"| clientClassPass end subgraph privateSessions ["Private appointments"] direction LR appointmentPass["
Appointment pass
/appointment-passes/
"] clientAppointmentPass(["
Client appointment pass
/client-appointment-passes/
"]) appointment("
Appointment
/appointments/
") clientAppointmentPass -->|"
appointment_pass_id
"| appointmentPass appointment -.->|"
spends credits of
"| clientAppointmentPass end class classPass,appointmentPass definition class clientClassPass,clientAppointmentPass held class booking,appointment record classDef definition fill:#beede5,stroke:#21837d,stroke-width:2px,color:#0f3d39 classDef held fill:#ece4f8,stroke:#6b4fa3,stroke-width:2px,color:#35205f classDef record fill:#fef3c7,stroke:#d97706,stroke-width:2px,color:#5e2a0c classDef person fill:#e5eaea,stroke:#565e5d,stroke-width:2px,color:#1e2323 linkStyle default stroke-width:1.5px ``` A booking names the client class pass to use. An appointment does not: bsport spends the credits of the compatible client appointment pass that expires first. The credits come from the slot's `credit_price`. # Create catalogue items Use this guide to create gift cards and retail products, and to apply the rules for discount codes. The following requirements depend on the requested item type. Supply all other required fields shown in the reference as well. | Type | Requirements | | ------------------ | ---------------------------------------------------------------------------------------------------------------- | | Fixed gift card | Supply `fixed_amount`; omit or null both flexible bounds. | | Flexible gift card | Supply `minimum_amount` and `maximum_amount`, with minimum no greater than maximum; omit or null `fixed_amount`. | | Standalone product | Omit `base_product_id`; leave `color` and `size` empty. | | Base product | Omit `base_product_id`; leave variant attributes empty and `stock_quantity` at zero. | | Variant | Supply `base_product_id` and at least one non-blank variant attribute (`color` or `size`). | Discount codes (the `/coupons/` resource) apply to one-off purchases only. Discount codes configured for subscriptions are not exposed and `subscription_mode` is not part of the contract. Discount code usages (`/coupon-usages/`) are read-only: `POST /coupon-usages/` and `PATCH /coupon-usages/{id}/` return `405`. Discount codes use `expiration_date` and the read-only `is_disabled` field. Gift-card `fixed_amount` accepts two fractional digits. Company financial configuration can prevent gift-card or sellable-product creation or activation. This setup is not editable through V2. Arrange it with the company in Back Office before repeating a rejected request; changing unrelated request fields will not resolve it. # Manage clients, notes and tags Use this guide to update clients and to manage client notes, tags and tag groups. For a compact V2 client list, use `GET /clients/?fields=id,email`. The optional `fields` parameter selects comma-separated public output names; omission returns the full client representation. Empty, duplicate or unknown names and repeated `fields` parameters return `400`. Values and nulls retain their usual meaning; `phone_number` is still absent when no phone exists. Filters, company isolation and the pagination envelope, including `next_page`, are unchanged. If combining field selection with `expand[]`, select every expanded root field as well. `PATCH /clients/{id}/` updates the supported client fields. Email is accepted at creation and is read-only afterward: sending it in a `PATCH` returns `400`. `is_email_accepted` reports marketing-email consent and can be set at creation or updated independently. Tags and billing venues must belong to the authenticated company. Otherwise the request is rejected before any change is written. Client notes, tags and tag groups support `PATCH` and `DELETE`. | Resource | What to know | | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Notes | Creating a note for an unknown client or a client of another company is rejected before any write. Responses expose the date as `creation_date`. | | Tags | `color` is required and must be lowercase hexadecimal in `#rrggbb` format. The tag group must belong to the authenticated company. Deleting a tag removes its usages. | | Tag groups | Duplicate names and franchisor-managed groups are rejected without a partial write. Deleting a group deletes its tags. | # Read billing data Use this guide to read invoices and invoice items and to interpret amount units. List `/invoices/` for invoice totals and `/invoice-items/` for item-level amounts. Filter by `client_id` or issue dates before paginating. Use an invoice UUID, not a numeric line-item ID, when retrieving `/invoices/{id}/`. ## How invoices, items and discount codes connect Color and shape show what kind of resource a box is. Teal rectangles are set up by the studio, purple pills are held by a client, amber rounded boxes are records of something that happened, and the grey hexagon is the client. A solid arrow starts at the resource that holds an ID and ends at the resource the ID refers to. A dotted arrow is a relationship without an ID field. ``` %%{init: {"flowchart": {"curve": "basis", "nodeSpacing": 45, "rankSpacing": 60, "padding": 14}}}%% flowchart LR client{{"Client
/clients/"}} invoice("Invoice
/invoices/") item("Invoice item
/invoice-items/") code["Discount code
/coupons/"] usage("Discount code usage
/coupon-usages/") invoice -->|"client_id"| client item -->|"invoice_id"| invoice usage -->|"coupon_id"| code usage -->|"invoice_id"| invoice usage -->|"client_id"| client class client person class code definition class invoice,item,usage record classDef definition fill:#beede5,stroke:#21837d,stroke-width:2px,color:#0f3d39 classDef held fill:#ece4f8,stroke:#6b4fa3,stroke-width:2px,color:#35205f classDef record fill:#fef3c7,stroke:#d97706,stroke-width:2px,color:#5e2a0c classDef person fill:#e5eaea,stroke:#565e5d,stroke-width:2px,color:#1e2323 linkStyle default stroke-width:1.5px ``` Every amount is a decimal string in major currency units, and every rate a decimal-string percentage. See [Dates, time zones and amounts](https://api-docs.production.bsport.io/guides/12-dates-time-zones-and-amounts.html). | Field family | Representation | | --------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | | Invoice `total_amount`, `paid_amount`, `pending_amount`, `outstanding_amount`, and the nested `line_items.data` amounts and tax amounts | Decimal strings in major currency units: `"49.00"` means EUR 49.00 when `currency=EUR`. | | Invoice line tax `rate`, product `tax_rate` | Percentages: `"20.000"` means 20%, not 0.20. | | Gift-card `fixed_amount` | Decimal string in major currency units. | | Gift-card `minimum_amount`, `maximum_amount` | Decimal strings of whole amounts: `"10.00"`. An amount with cents is refused. | For subscription billing, `interval_unit` is `day`, `week`, `month` or `year`. `recurrence_basis` is the number of these units between recurring billing dates; for example, 2 and `month` describe a two-month interval. # Schedule and cancel classes Use this guide to schedule, update and cancel classes as a manager. A service spans several venues, teachers and levels and carries no price of its own, so the API cannot infer them. `POST /api/v2/management/classes/` requires eight fields: `service_id`, `venue_id`, `teacher_id`, `level_id`, `credit_price`, `starts_at`, `duration_in_minutes` and `max_capacity`. Omitting one returns `400` naming the field. bsport resolves the internal record for that combination and creates it when the combination is new. Get the values from these endpoints. | Field | Where to obtain it | | ------------------------ | ----------------------------------------------------------------------------------------------------------------------- | | `service_id` | `/services/` | | `level_id` | `/levels/`. It lists your company's levels and the levels shared across companies. A level you cannot use returns `400` | | `teacher_id`, `venue_id` | `/teachers/`, `/venues/` | `PATCH /classes/{id}/` is fully partial: every field is optional and only the fields you send are applied. Capacity cannot drop below the current confirmed booking count. For a class owned by a class group, update the group instead of sending `service_id`, `level_id` or `is_bookable_by_clients` to the individual class. Update linked hybrid classes through their paired management flow, not one side at a time. `POST /classes/{id}/cancel/` cancels a class and refunds its active bookings. `should_notify_participants` defaults to `false`. Detail operations are not limited to the default 30-day list window. A class or appointment scheduled further ahead can be retrieved, updated and canceled by ID without a query parameter. # Send an email or SMS Use this guide to queue an email or SMS to clients and follow its processing status. Both channels use `POST /api/v2/management/communications/`. In the reference, select the email or SMS request variant; `channel` identifies which contract you are sending. Use the authentication and JSON headers shown in the [class booking example](https://api-docs.production.bsport.io/guides/tasks/book-classes-and-appointments.html#book-classes). An email requires a non-blank subject and accepts up to 10,000 message characters. ```json {"channel":"email","client_ids":[123],"subject":"Your next visit","message":"Hello {firstname}, we look forward to seeing you."} ``` An SMS accepts up to 1,000 message characters and must omit `subject` entirely. ```json {"channel":"sms","client_ids":[123],"message":"Hello {firstname}, your session starts at 10:00."} ``` Each request accepts 1 to 100 distinct client IDs. Recipient placeholders in message text include `{firstname}`, `{lastname}`, `{client_id}` and `{unsubscribe_link}`. Names come from the recipient's client profile; an empty name supplies an empty value. `{client_id}` is the ID of the client listed in `client_ids`, as returned by the Clients endpoint. A shared contact receives that client's values, so its `{client_id}` is the listed client's ID, not the ID of the client who owns the address. Company placeholders include `{company_name}` and `{currency}`. The request does not accept a custom placeholder map. Avoid unrecognised placeholders: they are not a supported way to supply application data. The client list is not an exclusive delivery list Shared-contact and household relationships can add recipients beyond `client_ids`. Do not use this endpoint for content that must go exclusively to the listed people. `recipient_count` counts associated recipient records, not confirmed deliveries. A `202` response returns `id`, `channel` and `status=queued`. Save that ID and retrieve `/communications/{id}/` to follow processing. The available states have these meanings. | Status | Meaning | | ----------- | -------------------------------------------------------------------------------- | | `queued` | Processing is pending. | | `processed` | Processing finished; delivery to each recipient is not confirmed. | | `failed` | Processing failed. This does not establish that no recipient received a message. | | `unknown` | A processing status cannot be provided. | | `sent` | Reserved; currently not returned. | There is no idempotency key. After a lost response, the API provides no correlation filter to identify that attempt conclusively. Do not automatically resend: that can duplicate messages. Reads only return messages queued through this API, not Back Office or automation sends. Sending has a separate limit of 10 requests per minute per company and franchise context, shared across API keys and managers. See [Rate limits](https://api-docs.production.bsport.io/guides/06-rate-limits.html). # Understand updates and disabling Read this page before you send a `PATCH` or an enable or disable action. It lists the side effects that affect integrations. Read the operation's documented side effects before sending a PATCH or action request. The following effects are especially relevant to integrations. | Operation | Effect to account for | | -------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | | PATCH a class's `service_id` or `teacher_id` | Clears the substitute teacher unless `substitute_teacher_id` is also supplied. | | PATCH a class's time, duration or venue | Can recreate a published class on an external aggregator; existing aggregator bookings may not be retained. | | PATCH a venue | For a venue historically associated with several companies, all associated companies observe the update. | | Disable a discount code (coupon) | Permanently archives it and retires its codes; there is no enable operation. | | Disable a base product | Also disables its enabled variants. Enable the base before enabling a variant. | | Enable or disable a client class pass | Omit `should_spread_to_shared_passes` or use `false`; `true` is rejected with `400`. | | Disable a client appointment pass | Also disables synchronized copies; it does not refund the purchase. | For class-pass time restrictions, `off_peak_schedule` maps ISO weekday numbers as strings (`"1"` for Monday through `"7"` for Sunday) to arrays of start/end times in the company timezone. For example, `{"1":[["09:00","12:00"]]}` specifies a Monday interval. An empty object means no off-peak restriction. Do not treat this field as a complete booking-eligibility check: credits, pass validity, service restrictions and booking windows also apply. # Webhooks # Build real-time integrations with webhooks Receive an HTTPS request as soon as a supported resource or relation changes in bsport. Most Public API webhook events send the same resource shape exposed by the V2 REST API; relation and delete events use the event-specific schema shown in the catalogue. Payload version New registrations are always created through the V2 route and deliver V2 payloads with canonical event names such as `class.updated`. Existing registrations keep delivering V1 payloads and historical event names. See [Webhook event payloads](https://api-docs.production.bsport.io/webhooks/05-event-payloads.html#payload-versions). [Set up an endpoint](https://api-docs.production.bsport.io/webhooks/01-public-api-webhooks.html) [Explore events](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html) Back Office webhooks are being retired Existing Back Office webhooks are configured in `Settings > Webhook`. They use a separate legacy registration system and legacy payloads. All new webhook integrations must be created and managed through the Public API. Read [Migrating from Back Office webhooks](https://api-docs.production.bsport.io/webhooks/03-backoffice-webhooks.html) if an existing integration still depends on the legacy system. ## One contract from event to API Every Public API webhook delivery uses the same envelope: ```json { "event_type": "class.updated", "date": 1787394600, "data": { "id": 186280, "company_id": 2, "name": "Morning yoga" } } ``` - `event_type` identifies exactly what changed. - `date` is the Unix timestamp of the captured database change. - `data` contains the event-specific payload. The event catalogue expands its complete schema. ## Integration path 1 ### Create a registration Subscribe a company to one event using the Public API registration endpoint. 2 ### Verify every request Validate the HMAC signature against the raw request body before processing data. 3 ### Process idempotently Store the delivery identifier and return a 2xx response only after accepting the event. ## Available resources [**Classes** Creation and updates](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html#webhook/class.created) [**Bookings** Creation, updates and deletion](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html#webhook/booking.created) [**Clients** Client and tag changes](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html#webhook/client.created) [**Teachers** Creation, updates and deletion](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html#webhook/teacher.created) [**Appointments** Creation, updates and cancellation](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html#webhook/appointment.created) [**Services** Creation and updates](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html#webhook/service.created) [**Venues** Company association and catalogue changes](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html#webhook/venue.created) [**Class passes** Creation and updates](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html#webhook/class_pass.created) [**Client class passes** Creation and updates](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html#webhook/client_class_pass.created) [**Products** Creation and updates](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html#webhook/product.created) [**Invoices** Invoice and line-item changes](https://api-docs.production.bsport.io/webhooks/invoice-webhook-v2.html) ## Continue New integrations use V2 payloads. Existing V1 registrations retain their historical contract; see [existing V1 registrations](https://api-docs.production.bsport.io/webhooks/06-v1-registrations.html) and the [full V1 event reference](https://api-docs.production.bsport.io/webhooks/05-v1-event-reference.html). - [Set up a webhook endpoint](https://api-docs.production.bsport.io/webhooks/01-public-api-webhooks.html) - [Explore the event catalogue](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html) - [Understand delivery, signatures and retries](https://api-docs.production.bsport.io/webhooks/04-delivery.html) # Set up a webhook endpoint Create and manage webhook registrations through the Public API. A registration subscribes one company to one event and sends deliveries to one public HTTPS URL. Back Office `Settings > Webhook` does not create these registrations and never displays them. ## Before you begin You need: - a company-manager Public API key; - the client and company identifiers used by your integration; - a public HTTPS endpoint that can read the raw request body and return a 2xx response. ## Create a registration ```bash curl --request POST \ --url 'https://YOUR_ENV_DOMAIN/api/v2/management/webhook-registrations/' \ --header 'X-Api-Key: YOUR_API_KEY' \ --header 'X-Client-ID: YOUR_CLIENT_ID' \ --header 'X-Company-ID: YOUR_COMPANY_ID' \ --header 'Content-Type: application/json' \ --data '{ "event_type": "class.updated", "url": "https://integrations.example.com/webhooks/bsport", "is_active": true }' ``` New registrations always use the immutable `payload_version` value `v2`. V1 creation returns HTTP `410` with code `WHR-002`. See [existing V1 registrations](https://api-docs.production.bsport.io/webhooks/06-v1-registrations.html) for historical integrations. Replace `YOUR_ENV_DOMAIN` with `public.production.bsport.io`. The response includes the generated `signing_secret`. Store it as a secret and use it to verify every delivery. The secret remains visible when the registration is listed or retrieved. Do not expose the signing secret Never put the signing secret in source control, application logs, issue trackers or client-side code. ## Payload version The registration decides which payload version it delivers. A new registration always delivers V2 payloads, because V1 creation is retired. Existing registrations keep delivering V1 payloads and historical event names. The version does not change after creation. See [Webhook event payloads](https://api-docs.production.bsport.io/webhooks/05-event-payloads.html#payload-versions). ## Select an event Each registration accepts one `event_type` from the [event catalogue](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html). Create additional registrations when the same endpoint must receive several event types. ## Test a registration Send one signed sample delivery to the registration's URL and read what your endpoint answered. A test also works on an inactive registration: create it with `"is_active": false`, test it, then activate it. ```bash curl --request POST \ --url 'https://YOUR_ENV_DOMAIN/api/v2/management/webhook-registrations/REGISTRATION_ID/test/' \ --header 'X-Api-Key: YOUR_API_KEY' \ --header 'X-Client-ID: YOUR_CLIENT_ID' \ --header 'X-Company-ID: YOUR_COMPANY_ID' ``` The response reports your endpoint's answer: ```json { "is_delivered": true, "http_status": 200, "failure_reason": null } ``` `is_delivered` is true only for a 2xx status. Redirects are not followed, as for real deliveries. The sample delivery has the envelope, headers and signature of a real delivery for the registration's event and payload version, so a V1 registration receives a V1 sample. Its `data` holds placeholder values generated from the event's schema in the [event catalogue](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html), such as `0` for IDs, never a real record of your company. A handler that fetches the resource by its ID gets a `404`. Each test is sent once, without retry, with a new `X-Bsport-Webhook-Delivery-Id`. You can send 5 tests per minute per company: see [Rate limits](https://api-docs.production.bsport.io/guides/06-rate-limits.html). When no response was received, `http_status` is null and `failure_reason` gives the cause: | `failure_reason` | Cause | | ------------------------- | ------------------------------------------------------------------------------------------------------------- | | `connect_timeout` | No connection opened within 2 seconds. | | `read_timeout` | No response byte within 5 seconds of sending the request or of the previous byte. | | `network_error` | The host name did not resolve or the connection failed. | | `invalid_destination_url` | The host resolves to a non-public address, or the URL is invalid. The address is checked again on every test. | | `tls_verification_error` | The endpoint's TLS certificate was rejected. | ## Update or disable a registration Use `PATCH` to change the destination, event or active state. Updating a registration preserves its signing secret and immutable payload version. To replace a leaked secret, see [Rotate the signing secret](https://api-docs.production.bsport.io/webhooks/04-delivery.html#rotate-the-signing-secret). The V2 route manages both V1 and V2 registrations. When updating a V1 registration, use its historical event names. The V1 route remains available for managing existing V1 registrations. ```bash curl --request PATCH \ --url 'https://YOUR_ENV_DOMAIN/api/v2/management/webhook-registrations/REGISTRATION_ID/' \ --header 'X-Api-Key: YOUR_API_KEY' \ --header 'X-Client-ID: YOUR_CLIENT_ID' \ --header 'X-Company-ID: YOUR_COMPANY_ID' \ --header 'Content-Type: application/json' \ --data '{"is_active": false}' ``` Webhook registrations cannot be deleted through the API. Disable a registration to stop future deliveries without losing its configuration. ## Tenant isolation List and retrieve operations return only registrations owned by the authenticated company. A registration belonging to another company is not visible or mutable, even when its identifier is known. ## Next step Implement [signature verification and idempotent delivery handling](https://api-docs.production.bsport.io/webhooks/04-delivery.html), then use the [event catalogue](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html) to model the events you subscribe to. # Webhook event payloads Create and update events use the same unexpanded resource representation as the corresponding retrieve endpoint. Relation events and true delete events use the smaller shapes documented below. ## Payload versions The payload version belongs to the registration, not to the event. | Registration | Event names | `data` follows | | ---------------------------------------------------------------- | -------------------------------------- | ----------------------------------- | | New, created through `/api/v2/management/webhook-registrations/` | Canonical, for example `class.updated` | The V2 retrieve endpoint | | Existing, created before payload versioning | Historical, for example `offer-update` | The V1 retrieve endpoint, unchanged | V1 registration creation is retired: `POST` on `/api/v1/management/webhook-registrations/` returns `410` with code `WHR-002`. Existing registrations keep delivering V1 payloads and do not change on their own. This includes registrations that were created through a V2 route before payload versioning was introduced. To receive V2 payloads for an event you already follow, create a new registration for the V2 event, then disable the old one when your receiver handles the new shape. While both exist, send them to separate receiver URLs so each endpoint parses a single version. See [existing V1 registrations](https://api-docs.production.bsport.io/webhooks/06-v1-registrations.html). ## Event names and historical terms New registrations use canonical event names that match the REST resource: `class.updated` carries a Class, `client.updated` carries a Client, `teacher.updated` carries a Teacher. Existing V1 registrations keep inherited Back Office names (`offer-update`, `member-update`, `associated_coach-update`, `tag_member-create`). These are not REST resource names: the API has no `/offers/`, `/members/` or `/associated_coaches/` resource. Use the `data` model name when you name the object in your application. For example, `offer-update` carries a Class resource, not a separate Offer model. The [historical V1 catalogue](https://api-docs.production.bsport.io/webhooks/05-v1-event-reference.html) lists those names. ## Resource mapping | Event family | `data` resource | Corresponding endpoint | | -------------------------------------------------------------------- | ------------------- | -------------------------------------------------- | | `appointment.created`, `appointment.updated`, `appointment.canceled` | Appointment | `GET /api/v2/management/appointments/{id}/` | | `service.created`, `service.updated` | Service | `GET /api/v2/management/services/{id}/` | | `venue.created`, `venue.updated`, `venue.deleted` | Venue | `GET /api/v2/management/venues/{id}/` | | `class.created`, `class.updated` | Class | `GET /api/v2/management/classes/{id}/` | | `booking.created`, `booking.updated`, `booking.deleted` | Booking | `GET /api/v2/management/bookings/{id}/` | | `client.created`, `client.updated` | Client | `GET /api/v2/management/clients/{id}/` | | `client.tag_added`, `client.tag_removed` | Client-tag relation | Use `data.client_id` and `data.tag_id` directly | | `teacher.created`, `teacher.updated`, `teacher.deleted` | Teacher | `GET /api/v2/management/teachers/{id}/` | | `invoice.created`, `invoice.updated` | Invoice | `GET /api/v2/management/invoices/{id}/` | | `class_pass.created`, `class_pass.updated` | Class pass | `GET /api/v2/management/class-passes/{id}/` | | `client_class_pass.created`, `client_class_pass.updated` | Client class pass | `GET /api/v2/management/client-class-passes/{id}/` | | `product.created`, `product.updated` | Product | `GET /api/v2/management/products/{id}/` | The [webhook event catalogue](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html) shows the complete schema and example for every event. Do not mix V1 and V2 identifiers A V1 registration delivers V1 field names and IDs. Booking `session_id` is `class_id` in V2, and a class `service_id` or `teacher_id` from a V1 payload does not identify the same record as the field of the same name in V2. When you run both versions, do not store or compare IDs across them. If you stay on a V1 registration but work with V2, use the event as a trigger and fetch the resource from V2 by ID. ## V1 payloads compared with V2 This table is for integrations that still receive V1 payloads from older registrations. Read it by resource. The left column is what a V1 registration delivers. The right column is what a V2 registration delivers, which is the same as the V2 REST response. | Resource | V1 registration `data` | V2 registration `data` | | -------- | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | | Booking | `session_id`, `session_start_at`, `client_pass_id`, `location_id` | `class_id`, `class_start_at`, `client_class_pass_id`, `venue_id` | | Class | `is_cancelled`, `cancellable_until`, `is_bookable_by_members` | `is_canceled`, `cancelable_until`, `is_bookable_by_clients` | | Class | `current_waiting_list_size`, `max_waiting_list_size` | `current_waitlist_size`, `max_waitlist_size` | | Class | `service_id`: internal scheduling record | `service_id`: the service returned by `/services/` | | Class | `teacher_id`: the teacher running the class (the substitute when assigned) | `teacher_id`: the main teacher. `substitute_teacher_id` is separate | | Class | No `level_id` | `level_id` | | Teacher | `first_name`, `last_name`, `phone` | `firstname`, `lastname`, `phone_number` | | Client | `membership_id`, `default_billing_establishment_id`, `general_terms_*_accepted_date` | `client_reference_number`, `default_billing_venue_id`, `general_terms_*_accepted_at` | The [migration guide](https://api-docs.production.bsport.io/guides/11-migrate-from-v1-to-v2.html) lists every other renamed field. ## Current-state events Create and update events contain the resource's current state when the delivery is prepared. A consumer can usually process `data` directly. Fetch the retrieve endpoint when the integration needs a later state or when it deliberately expands related resources. Invoice identifiers are UUID strings. `invoice.updated` also reports invoice-item creation, updates, and deletion; reassignment can notify both the old and new invoice. The payload includes the current grouped `line_items`, not the historical row mutation. Multiple row changes can produce multiple deliveries for the same invoice. Renaming what a line sells, such as a product, also emits `invoice.updated`. See [Invoice events](https://api-docs.production.bsport.io/webhooks/invoice-webhook-v2.html) for the trigger boundaries; there is no `invoice.deleted` or invoice payment-transition event. `appointment.canceled` records entry into a canceled status, but its payload is also read at delivery time and can reflect a later reactivation. An appointment without an addressable company client is omitted from V2 lists, returns 404 on retrieval, and is not delivered. Class pass, client class pass, and product updates also cover changes to related data, such as pass access rules, shared-pass bookings and dates, or product stock and inherited tax. An update is a refresh notification, not a field-level difference: related changes can produce several notifications with identical `data`. Replace your stored resource state rather than adding credits or stock for every notification. These families expose only `created` and `updated`. They do not signal that a payment succeeded or that a pass expired merely because its end date passed. A client class pass without a client belonging to the class pass owner's company is not available through V2: lists omit it, detail requests return 404, and current-state webhook delivery is skipped. The underlying pass is not deleted or disabled by this rule. ```python def handle_class_update(payload): class_data = payload["data"] synchronize_class( class_id=class_data["id"], starts_at=class_data["starts_at"], capacity=class_data["max_capacity"], ) ``` ## Delete and catalogue-removal events True resource deletions cannot be serialized after the database row has disappeared. `booking.deleted` and `teacher.deleted` therefore contain only: ```json { "data": { "id": 123 } } ``` `venue.deleted` uses the same ID-only shape when a venue association is removed from the subscribing company's catalogue. The venue can still exist for another company. Reassigning an association emits removal for its previous company and creation for its new company. `client.tag_added` and `client.tag_removed` identify the changed relation directly: ```json { "data": { "client_id": 123, "tag_id": 456 } } ``` ## Unexpanded related resources In current-state resource payloads, expandable fields such as `teacher_id`, `venue_id` or `client_id` are identifiers. Use those identifiers with the relevant Public API endpoint when the related object is required. Relation and ID-only payloads have no expandable fields. ## Legacy payloads These rules apply only to registrations created through the Public API. Webhooks configured in Back Office `Settings > Webhook` use older payloads and are being retired. See [Migrating from Back Office webhooks](https://api-docs.production.bsport.io/webhooks/03-backoffice-webhooks.html) for the transition path. Do not carry legacy field names into a new Public API integration. # Delivery, signatures and retries Public API webhooks are signed HTTPS POST requests. Verify the signature against the raw body, accept deliveries idempotently and return a 2xx response only after the event has been safely queued or persisted. ## Delivery envelope The envelope always contains exactly three top-level fields: | Field | Type | Meaning | | ------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | | `event_type` | string | Exact event name selected by the registration. | | `date` | integer | Unix timestamp in seconds of the captured database change. | | `data` | object | Event-specific Public API resource documented in the [event catalogue](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html). | The payload version is carried in a header, not in the body. The frozen envelope remains `{event_type, date, data}`. ## Verify the signature `Bsport-Signature` uses a Stripe-style timestamped HMAC-SHA256 value: ```text t=1787394600,v1=64-character-lowercase-hex-digest ``` `t` is the Unix timestamp of the attempt, so every retry carries a new `t` and a new `v1`. To verify a delivery: 1. Read the raw request bytes before JSON parsing or reformatting. 1. Extract `t` and `v1` from `Bsport-Signature`. 1. Build the signed bytes as `.`. 1. Compute HMAC-SHA256 using the registration's complete `signing_secret`, including its `whsec_` prefix, as the key. 1. Compare the computed lowercase hexadecimal digest with `v1` using a constant-time comparison. 1. Reject timestamps outside the tolerance chosen by your integration, for example five minutes. This Python function applies those steps: ```python import hashlib import hmac import os import time SIGNING_SECRET = os.environ["BSPORT_WEBHOOK_SIGNING_SECRET"] TOLERANCE_SECONDS = 300 def verify_bsport_signature(raw_body: bytes, signature_header: str) -> None: fields = dict(field.split("=", 1) for field in signature_header.split(",")) timestamp, signature = fields.get("t", ""), fields.get("v1", "") signed_bytes = timestamp.encode() + b"." + raw_body digest = hmac.new(SIGNING_SECRET.encode(), signed_bytes, hashlib.sha256).hexdigest() if not hmac.compare_digest(digest.encode(), signature.encode()): raise ValueError("Invalid signature") if abs(time.time() - int(timestamp)) > TOLERANCE_SECONDS: raise ValueError("Timestamp outside tolerance") ``` The `v1` token identifies the signature algorithm. It is independent from the dated payload schema version. ## Rotate the signing secret Rotate the secret when it may have leaked. The response is the registration with its new `signing_secret`; its event, URL, active state and payload version do not change. ```bash curl --request POST \ --url 'https://YOUR_ENV_DOMAIN/api/v2/management/webhook-registrations/REGISTRATION_ID/rotate-secret/' \ --header 'X-Api-Key: YOUR_API_KEY' \ --header 'X-Client-ID: YOUR_CLIENT_ID' \ --header 'X-Company-ID: YOUR_COMPANY_ID' ``` The previous secret stops working at once, with no grace period: - every delivery attempt made after the rotation is signed with the new secret, including retries of events that first failed before it; - a delivery already being sent at the moment of rotation carries the previous signature. Deploy the new secret to your endpoint right after rotating. Until then, its signature checks fail: answer with a `5xx` status rather than `401` during that window, because `5xx` responses are retried and other `4xx` responses are not (see [Automatic retries](#automatic-retries)). Rotation is not idempotent: each call generates another secret. After an uncertain result, retrieve the registration to read its current secret instead of rotating again. ## Delivery headers Every delivery attempt sends these headers: | Header | Meaning | | ----------------------------------- | --------------------------------------------------------------------------------- | | `Content-Type` | `application/json`. | | `Bsport-Signature` | Timestamp and HMAC-SHA256 signature. | | `X-Bsport-Webhook-Payload-Version` | `2026-10-06` for V2 registrations; `2026-08-22` for existing V1 registrations. | | `X-Bsport-Webhook-Delivery-Id` | Stable UUID for the logical delivery. | | `Idempotency-Key` | Same stable delivery UUID. | | `X-Bsport-Webhook-Delivery-Attempt` | One-based attempt count, which keeps increasing across a manual replay. | | `X-Bsport-Webhook-Retry-Number` | `0` on the first attempt and on a manual replay, then the scheduled retry number. | ## Respond quickly and idempotently Return a 2xx response after the event has been accepted for processing. Each attempt allows 2 seconds to open the connection and fails if no response byte arrives for 5 seconds, so queue slow work instead of finishing it before you respond. Only the status code counts: the response body is ignored and redirects are not followed. Delivery is at least once: the same logical delivery is sent again after a timeout or retryable status. An interruption on the bsport side can also repeat a delivery your endpoint already accepted with a 2xx response. Use `X-Bsport-Webhook-Delivery-Id` as the deduplication key. The identifier remains stable across automatic retries and manual replay, while the attempt and retry headers change. Deliveries can arrive out of order: a retry can reach your endpoint after a later event for the same resource. `date` records when each change happened, to the second, so it cannot order changes made within the same second. When order matters, for example between `client.tag_added` and `client.tag_removed`, fetch the resource from the matching V2 retrieve endpoint instead of applying events in arrival order. ## Automatic retries A failed attempt gets up to four automatic retries, so a delivery has at most five attempts. Each delay is a minimum, counted from the failure of the previous attempt: 1. 10 seconds; 1. 1 minute; 1. 5 minutes; 1. 30 minutes. The fourth retry therefore comes at least 36 minutes after the first failure. A `Retry-After` response header has no effect on these delays. The result of an attempt decides whether it is retried: | Attempt result | Retried | | -------------------------------------------------------------------------------------- | ------- | | `408`, `425`, `429` or `5xx` response | Yes | | Timeout or network error | Yes | | Any other `4xx` response | No | | `3xx` response | No | | Rejected TLS certificate, or a URL that is invalid or resolves to a non-public address | No | ### Changes between attempts Each attempt reads the registration again, and [current-state events](https://api-docs.production.bsport.io/webhooks/05-event-payloads.html#current-state-events) also read `data` again. A retry therefore: - goes to the registration's current URL, signed with its current secret; - can carry newer `data` than the attempt that failed; - is dropped, with no request sent, when the registration has been disabled, its event has been changed, or the resource of a current-state event no longer exists. ### After the last attempt When no attempt is left, the delivery moves to a dead-letter queue. This happens after the fourth retry, or at once after a failure that is not retried. The Public API has no route to list or replay these deliveries. Replay is run by the bsport team, so contact them if you need one. A replay sends the same delivery ID with current-state `data` read again. Do not rely on replay to recover from an outage: read the state you missed from the matching V2 list or retrieve endpoints. ## Payload evolution The registration's `payload_version` is immutable. Retries and replay retain its contract. V2 payloads continue using the `v1` signature algorithm token. Read `X-Bsport-Webhook-Payload-Version` before decoding the body. Header versions are dates: `2026-10-06` for V2 and `2026-08-22` for V1. Registration versions are `v2` and `v1`. Within a version, new optional fields can appear without a new date, so ignore fields you do not recognize. Continue accepting the versions your integration understands and alert on an unfamiliar value before silently processing it. Do not answer `5xx` to an unfamiliar version: retries carry the same version and only use up the schedule. Store the verified body with its `X-Bsport-Webhook-Payload-Version` and `X-Bsport-Webhook-Delivery-Id` values, answer `2xx`, and process it once your integration supports that version. Payloads can contain personal data, so restrict access to stored bodies and delete them after a set period. # Invoice webhooks (V2) Create an invoice webhook registration through `/api/v2/management/webhook-registrations/`. Its payload uses the same invoice representation as `/api/v2/management/invoices/{id}/`, without expansions. Invoice identifiers are UUIDs. | Event | Trigger | | ----------------- | --------------------------------------------------------------------------------- | | `invoice.created` | An invoice is inserted. | | `invoice.updated` | An invoice is updated, or one of its line items is inserted, updated, or deleted. | Moving a line item to another invoice notifies both invoices. Each notification belongs to the company that issued that invoice, even when its client or a line item's cached company field belongs to another company. Each delivery attempt reads the invoice's current state, including its line items. The payload is not a snapshot of the invoice when the change occurred. Retries can therefore contain newer state. A transaction that changes several rows can produce several notifications; consumers should synchronize by invoice ID and handle duplicate delivery identities. Renaming what a line sells, such as a product or a class pass, changes that line's `description` and produces `invoice.updated` for every invoice that bills it. Changing a company's currency does not by itself produce an invoice notification; the next invoice or line-item notification includes the then-current representation. Deleting an invoice does not emit an `invoice.deleted` event; a pending notification whose invoice no longer exists is discarded. Payment, finalization, and refund flows produce `invoice.updated` when they update the invoice. This event does not mean that payment succeeded. Read `status`, `paid_amount`, and `outstanding_amount` from the payload instead of treating every update as a payment transition. [Detect invoice lifecycle steps](https://api-docs.production.bsport.io/webhooks/03-backoffice-webhooks.html#detect-invoice-lifecycle-steps) shows the change that marks each step. Existing [Backoffice invoice webhooks](https://api-docs.production.bsport.io/webhooks/invoice-webhook.html) retain their separate lifecycle events and payloads. Existing Public API V1 registrations cannot subscribe to the new invoice events. # Migrating from Back Office webhooks Move each Back Office webhook to a Public API webhook, then turn the Back Office webhook off. This page is for developers whose receiver gets Back Office webhooks today. It maps every Back Office event to its Public API event, lists the field changes, and walks through the switch. To build a new integration, start with [Set up a webhook endpoint](https://api-docs.production.bsport.io/webhooks/01-public-api-webhooks.html). If your company already receives Public API webhooks with historical names such as `offer-update`, read [Existing V1 registrations](https://api-docs.production.bsport.io/webhooks/06-v1-registrations.html) instead. Which webhooks are Back Office webhooks Back Office webhooks are configured in the Back Office settings: `Settings > Webhook` in the previous Back Office, and the **Legacy webhooks** table of `Settings > Webhooks & APIs` in the new one. They are being retired. Public API webhooks are a separate system: the Public API registration endpoints never return a Back Office webhook. ## What changes The table compares the two systems. Each row shows what your receiver handles today and what it handles after the move. | | Back Office webhook | Public API webhook | | ----------- | ------------------------------------------------------ | --------------------------------------------------------------------------------------------------------- | | Created in | Back Office settings | `POST /api/v2/management/webhook-registrations/`, or the **Webhooks** tab of `Settings > Webhooks & APIs` | | Event names | `booking-update`, `member-create` | `booking.updated`, `client.created` | | `data` | The record under a key: `data.booking`, `data.member` | The V2 resource itself: `data.id`, `data.client_id` | | Field names | Back Office names (`member`, `offer`, `establishment`) | V2 REST names (`client_id`, `class_id`, `venue_id`) | | Signature | None | `Bsport-Signature` header, HMAC-SHA256 | | Retries | None: one attempt | 4 retries with back-off for timeouts, network errors, `408`, `425`, `429` and `5xx` | Both keep the same envelope: `event_type`, `date` (Unix timestamp) and `data`. A similar event name does not mean the same payload `booking-update` and `booking.updated` report the same change with different payloads. Map every field your receiver reads with the tables below, and use the [event catalogue](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html) for the complete schema. Some IDs also change meaning: a Back Office teacher `id` and a Public API teacher `id` are different numbers for the same person. ## Event mapping The table lists every Back Office event. Find the event your webhook sends in the first column, register the event in the second column, and handle the changes in the third. In every Public API payload, `data` is the resource itself instead of a key such as `data.booking`. | Back Office event | Public API event | Main changes in `data` | | ---------------------------------------------------------------------- | --------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `booking-create`, `booking-update` | `booking.created`, `booking.updated` | `member` -> `client_id`, `offer` -> `class_id`, `offer_date_start` -> `class_start_at`, `consumer_payment_pack` -> `client_class_pass_id`, `establishment` -> `venue_id`, `date_canceled` -> `canceled_at`. `coach` held a coach ID; `teacher_id` holds a teacher ID from `/teachers/`. | | `booking-delete` | `booking.deleted` | `data` holds only the booking `id`. | | `offer-create`, `offer-update` | `class.created`, `class.updated` | `date_start` -> `starts_at`, `duration_minute` -> `duration_in_minutes`, `effectif` -> `max_capacity`, `meta_activity` -> `service_id`, `establishment` -> `venue_id`. `coach` held a coach ID; `teacher_id` holds the main teacher's ID from `/teachers/`. | | `member-create`, `member-update` | `client.created`, `client.updated` | `name` -> `fullname`, `birthday` -> `birth_date`, `tags` -> `tag_ids`, `archived` -> `is_archived`, `credit_account_balance` -> `client_account_balance`, `default_billing_establishment` -> `default_billing_venue_id`. The nested `consumer` object has no equivalent: read the client fields at the top level. | | `tag_member-applied`, `tag_member-removed` | `client.tag_added`, `client.tag_removed` | `data.member_tag.member` -> `data.client_id`, `data.member_tag.tag` -> `data.tag_id`. The relation's own `id` is not sent. | | `associated_coach-create`, `associated_coach-update` | `teacher.created`, `teacher.updated` | The teacher `id` is the Back Office `associated_coach_id`, not the Back Office `id`. `phone` -> `phone_number`, `disabled` -> `is_disabled`. | | `associated_coach-delete` | `teacher.updated` or `teacher.deleted` | The Back Office sent this event when a teacher was archived. Archiving now sends `teacher.updated` with `is_disabled` set to `true`. `teacher.deleted`, with only the `id`, means the teacher record was deleted. | | `invoice-create`, `invoice-update` | `invoice.created`, `invoice.updated` | New payload: build your parser from the [event catalogue](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html). | | `invoice-finalize`, `invoice-pay`, `invoice-dispute`, `invoice-revert` | `invoice.updated`, plus `invoice.created` for a reverse invoice | No dedicated event: see [Detect invoice lifecycle steps](#detect-invoice-lifecycle-steps). | | `billing_plan-create`, `billing_plan-update` | None | See [Billing-plan webhooks](#billing-plan-webhooks). | The Public API also sends events that Back Office webhooks never had: appointments, services, venues, class passes, client class passes and products. The [event catalogue](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html) lists them. ## Invoice webhooks `invoice.created` is sent for every new invoice, reverse invoices included. `invoice.updated` is sent for every change to an invoice or to its line items. A change of the company's currency alone sends nothing: the next invoice delivery carries it. Each delivery carries the invoice's current state, read when the delivery is prepared, not the change that triggered it. See [Invoice events](https://api-docs.production.bsport.io/webhooks/invoice-webhook-v2.html) for what triggers each event. ### Invoice fields The table maps each field of the Back Office invoice payload (`data.object`, sent by `invoice-finalize`, `invoice-pay`, `invoice-dispute` and `invoice-revert`) to the Public API invoice in `data`. Amounts change unit: Back Office amounts are integers in minor units (`4900`), Public API amounts are decimal strings in major units (`"49.00"`), line items included. | Back Office `data.object` field | Public API `data` field | Note | | ------------------------------- | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `id` | `id` | Same invoice UUID. | | `status` | `status` | Same values. | | `invoice_number` | `legal_identifier` | | | `invoice_type` | `invoice_type` | Same values. `1` is a reverse invoice. | | `source_invoice_id` | `source_invoice_id` | Same invoice UUID: on a reverse invoice, the invoice it refunds. Null on every other invoice and on the reverse invoices of partial pass refunds, which are not linked to an invoice. | | `date_created` | `created_at` | | | `date_issued` | `issued_at` | Null on drafts, voided invoices, and invoices without a recorded issue date (older and imported invoices). The Back Office payload sent the invoice date in that case. | | `date_due` | None | It always held the invoice date, not a payment deadline. `issued_at` gives that date once the invoice is issued; while `issued_at` is null, no field replaces it. | | `date_cancelled` | `canceled_at` | | | `currency` | `currency` | | | `total`, `amount_due` | `total_amount` | Both held the same amount. | | `amount_paid` | `paid_amount` | | | None | `pending_amount`, `outstanding_amount` | Payments still processing, and what the client still owes. | | `customer` | `client_id` | `customer.id` was the client's user account ID, not the client ID. Get the name, email, phone, address and official document ID with `GET /api/v2/management/clients/{client_id}/`. | | `company` | `company_id` | The object held the company's own name and address. | | `line_items` | `line_items` | Same structure (`line_count`, `data`), amounts in major units. | | `invoice_pdf` | `invoice_pdf` | Same link. | | `receipt_pdf` | None | | | `object`, `data.date` | None | Use the envelope `date`. | ### Detect invoice lifecycle steps The Public API has no finalize, pay, dispute or revert event. Store the last `status` and `issued_at` you received for each invoice `id`, and compare each `invoice.created` and `invoice.updated` delivery with them: - On `invoice.created`, compare with a `null` status and `issued_at`: an invoice created, issued and paid in one sale arrives already `paid`. - On `invoice.updated` for an invoice you have no state for, store its state without treating it as a step: it is an existing invoice that changed. To start from a baseline instead, load the invoices you track with `GET /api/v2/management/invoices/` before you switch. The table gives the change that matches each Back Office event. | Back Office event | Detect it when | | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `invoice-finalize` | `issued_at` goes from null to a date. `status` is `open`, or already `paid` when nothing was due. | | `invoice-pay` | `status` becomes `paid`. `outstanding_amount` is `"0.00"`. | | `invoice-dispute` | `status` goes from `paid` back to `open`. | | `invoice-revert` | `status` becomes `refunded` (an issued invoice) or `voided` (a draft), and `canceled_at` is set. A refund also creates a reverse invoice: you receive `invoice.created` with `invoice_type` `1` and a negative `total_amount`. | One delivery can show two steps at once, for example an invoice finalized and paid in the same operation. Handle each step it shows. A step can also be skipped: each delivery carries the state when it is prepared, so an invoice paid and refunded within seconds can arrive already `refunded`. A refunded invoice keeps its `paid_amount`: above `"0.00"` means money was received before the refund. Compare with the state you stored, not with the event Most `invoice.updated` deliveries change neither `status` nor `issued_at`: a line item was added, or a product was renamed. Several changes close together can also produce several deliveries that all carry the latest state. Act on a step only when the delivered state differs from the state you stored, and deduplicate on `X-Bsport-Webhook-Delivery-Id`. ## Billing-plan webhooks No Public API webhook replaces `billing_plan-create` and `billing_plan-update`. They stop when Back Office webhooks are switched off. To follow client memberships, read them with `GET /api/v2/management/client-subscriptions/`: see the [API reference](https://api-docs.production.bsport.io/reference/01-scalar-v2.html). ## Migrate a webhook Follow these steps for each Back Office webhook. Keep the Back Office webhook active until the last step. ### 1. List your Back Office webhooks Open the **Legacy webhooks** table of `Settings > Webhooks & APIs` in the Back Office (`Settings > Webhook` in the previous Back Office). Note each event and destination URL, and the fields your receiver reads from each payload. ### 2. Update your receiver Give Public API deliveries their own URL, so each endpoint parses one payload format. For each Public API delivery: 1. Verify `Bsport-Signature` against the raw request body with the registration's `signing_secret`, as described in [Verify the signature](https://api-docs.production.bsport.io/webhooks/04-delivery.html#verify-the-signature). 1. Read `X-Bsport-Webhook-Payload-Version` (`2026-10-06` for these registrations) and alert on a value your receiver does not know: see [Payload evolution](https://api-docs.production.bsport.io/webhooks/04-delivery.html#payload-evolution). 1. Skip deliveries whose `X-Bsport-Webhook-Delivery-Id` you already processed. 1. Read `data` with the [event mapping](#event-mapping) above. 1. Return a `2xx` status once the delivery is stored. A `5xx` status or a timeout is retried; other `4xx` statuses are not. ### 3. Create the registration Create one registration per event. You need a company-manager Public API key. ```bash curl --request POST \ --url 'https://YOUR_ENV_DOMAIN/api/v2/management/webhook-registrations/' \ --header 'X-Api-Key: YOUR_API_KEY' \ --header 'X-Client-ID: YOUR_CLIENT_ID' \ --header 'X-Company-ID: YOUR_COMPANY_ID' \ --header 'Content-Type: application/json' \ --data '{ "event_type": "booking.updated", "url": "https://integrations.example.com/webhooks/bsport-v2", "is_active": true }' ``` Replace `YOUR_ENV_DOMAIN` with `public.production.bsport.io`. The response includes the registration `id` and its `signing_secret`. Store the secret as a secret: your receiver needs it to verify every delivery. Without an API key, create the webhook in the **Webhooks** tab of `Settings > Webhooks & APIs` and copy its signing secret there. **Update to V2** on a webhook in the **Legacy webhooks** table opens that form with its URL and Public API event: change the URL to your Public API endpoint. ### 4. Send a test delivery Send one signed sample delivery to the registration's URL: ```bash curl --request POST \ --url 'https://YOUR_ENV_DOMAIN/api/v2/management/webhook-registrations/REGISTRATION_ID/test/' \ --header 'X-Api-Key: YOUR_API_KEY' \ --header 'X-Client-ID: YOUR_CLIENT_ID' \ --header 'X-Company-ID: YOUR_COMPANY_ID' ``` `is_delivered` is `true` when your endpoint answered with a `2xx` status. The sample `data` holds placeholder values, such as `0` for IDs, so the test checks the signature and parsing, not your business logic. See [Test a registration](https://api-docs.production.bsport.io/webhooks/01-public-api-webhooks.html#test-a-registration). ### 5. Run both webhooks for a short check Leave the Back Office webhook active while the Public API webhook delivers to its new URL. Both report the same changes, so let only one of them act: keep processing Back Office deliveries, and log and compare the Public API ones. Switch processing to the Public API deliveries once you have received each event you subscribe to and its data matches what the Back Office webhook sent. Around the switch, one change can reach you from both webhooks, one before and one after it. Storing the state by resource ID absorbs that. When a delivery triggers an action, such as an email or an accounting entry, key the action on the resource ID and the state it records, not on the delivery, so the change acts once. To roll back before the next step, send `{"is_active": false}` to the registration with `PATCH` and keep processing Back Office deliveries. ### 6. Turn off the Back Office webhook Open the **Legacy webhooks** table of `Settings > Webhooks & APIs` and choose **Turn off** for the webhook. In the previous Back Office, delete it in `Settings > Webhook`. Turning off cannot be undone Turning off deletes the Back Office webhook. Do it only once your receiver processes Public API deliveries. ## Legacy reference links The previous Back Office payload pages remain reachable for existing integrations, but they are no longer part of the primary documentation navigation: - [Billing plan](https://api-docs.production.bsport.io/webhooks/billing-plan-webhook.html) - [Booking](https://api-docs.production.bsport.io/webhooks/booking-webhook.html) - [Coach](https://api-docs.production.bsport.io/webhooks/coach-webhook.html) - [Invoice](https://api-docs.production.bsport.io/webhooks/invoice-webhook.html) - [Member](https://api-docs.production.bsport.io/webhooks/member-webhook.html) - [Offer](https://api-docs.production.bsport.io/webhooks/offer-webhook.html) # Use cases # Use cases These guides cover common integration patterns for the bsport Public API, built on V2. Each guide describes the recommended approach, the relevant endpoints and webhooks, and the main constraints to know before building. Not the right page? - To do one job on one resource, such as booking a class or reading invoices, use the [V2 workflows and field conventions](https://api-docs.production.bsport.io/guides/10-v2-workflows.html). - To make a first request, start with [Getting started](https://api-docs.production.bsport.io/guides/00-getting-started.html). - To let an AI assistant work with your bsport data, see the [MCP overview](https://api-docs.production.bsport.io/guides/mcp.html). - To build an integration with an LLM, see [Using LLMs for custom integrations](https://api-docs.production.bsport.io/guides/05-using-llms-for-integrations.html). ## Available guides - [CRM and email automation](https://api-docs.production.bsport.io/use-cases/01-crm-automation.html): sync client data and tag changes into a CRM or marketing automation tool. - [Reporting and BI](https://api-docs.production.bsport.io/use-cases/02-reporting.html): pull operational data into a dashboard or data warehouse. - [Website schedule embed](https://api-docs.production.bsport.io/use-cases/03-website-embed.html): display live class and appointment schedules on an external website. ## Choosing the right approach Read the table by goal. Each row links to the guide to start with. | Goal | Guide | | ------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- | | Update contacts in a CRM when a client is created or updated | [CRM and email automation](https://api-docs.production.bsport.io/use-cases/01-crm-automation.html) | | Build a reporting dashboard with booking, client, and invoice data | [Reporting and BI](https://api-docs.production.bsport.io/use-cases/02-reporting.html) | | Show upcoming classes or appointments on a website | [Website schedule embed](https://api-docs.production.bsport.io/use-cases/03-website-embed.html) | Not sure if your use case is supported? Check the [API reference](https://api-docs.production.bsport.io/reference/01-scalar-v2.html) for the V2 operations that exist before you design an integration, and contact the bsport team before starting a complex one. # CRM and email automation Keep client profiles and segmentation in an external CRM without repeatedly polling the complete client list. ## What you can synchronize | Change | Public API event | Payload resource | | ------------------------- | -------------------- | ------------------------------ | | Member created | `client.created` | Client | | Member profile updated | `client.updated` | Client | | Tag added to a member | `client.tag_added` | `{client_id, tag_id}` relation | | Tag removed from a member | `client.tag_removed` | `{client_id, tag_id}` relation | Subscription events are not part of the current Public API webhook catalogue. For invoice synchronization, use [V2 invoice webhooks](https://api-docs.production.bsport.io/webhooks/invoice-webhook-v2.html), which report invoice and line-item mutations. Do not build a new integration against the legacy Back Office billing or invoice payloads. ## Architecture ```text Public API webhook → verify signature and deduplicate delivery → read the Client object from data → upsert the CRM contact ``` Public API webhook `data` already matches the unexpanded V1 Client retrieve response. The CRM fields listed below exist in both the V1 and V2 Client, so the same upsert code reads a webhook payload and a V2 response. An enrichment request is only required when the integration needs a related resource that is not in that model. ## Initial import Import existing clients before activating webhook registrations: ```python import time import requests # YOUR_ENV_DOMAIN: public.production.bsport.io BASE_URL = "https://YOUR_ENV_DOMAIN" HEADERS = { "X-Api-Key": "YOUR_API_KEY", "X-Client-ID": "YOUR_CLIENT_ID", "X-Company-ID": "YOUR_COMPANY_ID", } def fetch_all_clients() -> list[dict]: clients = [] page = 1 while True: response = requests.get( f"{BASE_URL}/api/v2/management/clients/", headers=HEADERS, params={"page_size": 100, "page": page}, ) response.raise_for_status() data = response.json() clients.extend(data["results"]) page = data["next_page"] if page is None: return clients time.sleep(0.3) ``` Use the Client `id` as the stable external identifier. Useful CRM fields include `email`, `firstname`, `lastname`, `phone_number`, `tag_ids`, `is_archived`, `is_email_accepted` and `is_sms_accepted`. ## Process ongoing changes Create V2 registrations for the four client events and route them to the same receiver: ```python from flask import Flask, jsonify, request app = Flask(__name__) MEMBER_RESOURCE_EVENTS = { "client.created", "client.updated", } TAG_RELATION_EVENTS = { "client.tag_added", "client.tag_removed", } @app.post("/webhook/bsport") def handle_bsport_event(): raw_body = request.get_data() verify_bsport_signature(raw_body, request.headers["Bsport-Signature"]) delivery_id = request.headers["X-Bsport-Webhook-Delivery-Id"] if delivery_was_processed(delivery_id): return jsonify({"status": "already_processed"}), 200 payload = request.get_json() event_type = payload["event_type"] if event_type in MEMBER_RESOURCE_EVENTS: client = payload["data"] upsert_crm_contact(external_id=client["id"], client=client) elif event_type in TAG_RELATION_EVENTS: relation = payload["data"] update_crm_tag( client_id=relation["client_id"], tag_id=relation["tag_id"], applied=event_type == "client.tag_added", ) mark_delivery_processed(delivery_id) return jsonify({"status": "accepted"}), 200 ``` Signature verification must use the raw request bytes before JSON parsing. See [Delivery, signatures and retries](https://api-docs.production.bsport.io/webhooks/04-delivery.html#verify-the-signature) for the complete algorithm. ## Keep tag mappings readable Client resource payloads contain the current `tag_ids` list. Relation events instead contain one numeric `client_id` and one numeric `tag_id`. Maintain a mapping between tag identifiers and the labels used by your CRM; apply or remove exactly the relation named by the event. ## Send messages from your CRM V2 can queue a plain-text email or SMS to up to 100 clients per request. The client list is not an exclusive recipient list, and a retry can send duplicates. Read [Send an email or SMS](https://api-docs.production.bsport.io/guides/tasks/send-an-email-or-sms.html#send-an-email-or-sms) before you use it. ## Fallback polling The clients endpoint does not currently expose an incremental `updated_at` filter. A polling fallback must therefore paginate the complete list and compare it with local state. Prefer webhooks for ongoing synchronization and keep polling as a lower-frequency reconciliation job. ## Related documentation - [Set up a webhook endpoint](https://api-docs.production.bsport.io/webhooks/01-public-api-webhooks.html) - [Client and tag events](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html) - [Webhook event payloads](https://api-docs.production.bsport.io/webhooks/05-event-payloads.html) # Reporting and BI Use this guide when your goal is to pull bsport operational data into a reporting dashboard, data warehouse, or analytics tool. ## Who this is for - Teams building custom management dashboards with KPIs on bookings, attendance, memberships, or revenue. - Data analysts loading bsport data into an external warehouse or BI tool (Metabase, Tableau, Looker, and similar). - Operators who need a consolidated view across multiple companies in a franchise network. Alternative: Data as a Service (DaaS) For enterprise reporting and BI use cases, bsport offers **Data as a Service**: a dedicated Databricks data warehouse with curated, business-friendly tables (members, classes, bookings, subscriptions, etc.) refreshed daily. **Benefits over the Public API:** - **Curated tables** aligned with Back Office naming (not technical API objects) - **Managed pipeline**: no need to build/maintain your own ETL - **Warehouse-style queries**: better for large reporting workloads than repeated API polling - **Tool freedom**: connect Power BI, Tableau, Airtable, or any BI platform directly - **Faster time-to-value**: start analyzing immediately without data modeling **Trade-offs:** - Batch refresh (~1pm CET daily, with data up to 5am CET) instead of real-time - Requires BI/data engineering capability to operate independently - Not available for Excel or Google Sheets direct connection **Is DaaS right for you?** Consider DaaS if you have a dedicated BI/data team, need custom analytics beyond standard dashboards, and prefer self-serve exploration over API engineering. To learn more or request onboarding, contact your account manager. ## What you can do | Data type | Endpoint | | ------------------------ | ------------------------------------------------------------------------- | | Client list | `GET /api/v2/management/clients/` | | Bookings | `GET /api/v2/management/bookings/` | | Classes and appointments | `GET /api/v2/management/classes/`, `GET /api/v2/management/appointments/` | | Client passes | `GET /api/v2/management/client-class-passes/` | | Client subscriptions | `GET /api/v2/management/client-subscriptions/` | | Invoices | `GET /api/v2/management/invoices/` | | Invoice items | `GET /api/v2/management/invoice-items/` | | Discount code usages | `GET /api/v2/management/coupon-usages/` | | Teacher pay rates | `GET /api/v2/management/teacher-pay-rates/` | Filter invoices by client and by issue or creation timestamp, then paginate. Invoice filters take timestamps, not dates: see [Date and timestamp filters](https://api-docs.production.bsport.io/guides/03-pagination-and-filtering.html#date-and-timestamp-filters). Invoice totals are decimal strings in major currency units; nested invoice line amounts are integers in minor currency units. See [V2 workflows](https://api-docs.production.bsport.io/guides/tasks/read-billing-data.html#read-billing-data). ## Recommended architecture: polling For reporting, a scheduled polling job is the approach with the fewest moving parts. You control the refresh frequency and keep data in your own store. ```text Scheduled job (daily or hourly) -> Public API calls with date filters -> Store results in your data warehouse or database -> BI tool reads from your data store ``` Avoid querying the Public API directly from your BI tool at report render time. Cache the data in your own store to avoid rate limit issues and ensure consistent report performance. ```python import requests import time from datetime import date, timedelta # YOUR_ENV_DOMAIN: public.production.bsport.io BASE_URL = "https://YOUR_ENV_DOMAIN" HEADERS = { "X-Api-Key": "YOUR_API_KEY", "X-Client-ID": "YOUR_CLIENT_ID", "X-Company-ID": "YOUR_COMPANY_ID", } def fetch_bookings(date_from: date, date_to: date) -> list: bookings = [] page = 1 while True: response = requests.get( f"{BASE_URL}/api/v2/management/bookings/", headers=HEADERS, params={ "page_size": 100, "page": page, "class_start_after": date_from.isoformat(), "class_start_before": f"{date_to.isoformat()}T23:59:59.999999", }, ) response.raise_for_status() data = response.json() bookings.extend(data["results"]) page = data["next_page"] if page is None: break time.sleep(0.3) # stay within rate limit return bookings # Run daily from a scheduler (cron, Airflow, Celery beat, etc.) yesterday = date.today() - timedelta(days=1) for booking in fetch_bookings(date_from=yesterday, date_to=date.today()): upsert_into_warehouse(booking) ``` See [Rate limits and bulk data sync](https://api-docs.production.bsport.io/guides/06-rate-limits.html) for initial load patterns and the specific warning about the `client-class-passes` endpoint at scale. ## Webhook alternative: near-real-time ingestion Create V2 registrations to push events directly into your warehouse as they happen. This removes the polling lag and reduces API quota usage for high-frequency data like bookings. ```text Public API event (booking.created, booking.updated, booking.deleted) -> your webhook endpoint -> upsert into warehouse -> BI tool reads from warehouse ``` ```python from flask import Flask, request, jsonify app = Flask(__name__) @app.route("/webhook/bsport", methods=["POST"]) def handle_bsport_event(): raw_body = request.get_data() verify_bsport_signature(raw_body, request.headers["Bsport-Signature"]) payload = request.get_json() event_type = payload["event_type"] if event_type == "booking.deleted": delete_booking_from_warehouse(payload["data"]["id"]) elif event_type in ("booking.created", "booking.updated"): upsert_into_warehouse({"type": "booking", **payload["data"]}) return jsonify({"status": "accepted"}), 200 ``` `verify_bsport_signature` is defined in [Delivery, signatures and retries](https://api-docs.production.bsport.io/webhooks/04-delivery.html#verify-the-signature). `data` is the complete V1 Booking resource for create and update events. It uses V1 field names such as `session_id` and `client_pass_id`, while the polling job above returns V2 names such as `class_id` and `client_class_pass_id`. Map both shapes to the same warehouse columns. A delete event contains only the deleted booking identifier. See the [event catalogue](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html) for both schemas. V2 webhook Booking payloads use the same V2 REST shape as the polling examples above. Existing V1 webhook registrations keep their historical contract; use the [V1 catalogue](https://api-docs.production.bsport.io/webhooks/05-v1-event-reference.html) when maintaining those integrations. Combine both approaches Run a daily polling job to backfill any missed events, and use webhooks for real-time ingestion. The polling job acts as a safety net when your webhook endpoint is unavailable. ## Franchise-level reporting To aggregate data across all companies in a franchise, use a Franchisor API key and loop over each company ID. ```python import requests import time from datetime import date, timedelta BASE_URL = "https://YOUR_ENV_DOMAIN" FRANCHISE_ID = "60" COMPANY_IDS = [1511, 918, 2334] # companies within the franchise BASE_HEADERS = { "X-Api-Key": "YOUR_FRANCHISOR_API_KEY", "X-Client-ID": "YOUR_CLIENT_ID", "X-Franchisor-ID": FRANCHISE_ID, } def fetch_bookings_for_company(company_id: int, date_from: date, date_to: date) -> list: headers = {**BASE_HEADERS, "X-Company-ID": str(company_id)} bookings = [] page = 1 while True: response = requests.get( f"{BASE_URL}/api/v2/management/bookings/", headers=headers, params={ "page_size": 100, "page": page, "class_start_after": date_from.isoformat(), "class_start_before": f"{date_to.isoformat()}T23:59:59.999999", }, ) response.raise_for_status() data = response.json() bookings.extend(data["results"]) page = data["next_page"] if page is None: break time.sleep(0.3) return bookings yesterday = date.today() - timedelta(days=1) for company_id in COMPANY_IDS: for booking in fetch_bookings_for_company(company_id, yesterday, date.today()): upsert_into_warehouse({**booking, "company_id": company_id}) ``` See [Headers and tenant context](https://api-docs.production.bsport.io/guides/01-authentication.html#tenant-and-client-headers) for the full header rules. ## Limitations - The `GET /api/v2/management/client-class-passes/` endpoint can time out on companies with a large number of passes if queried without filters. Always apply a `client_ids` or date filter. - Use `expand[]=class_id` to include class details in booking results, or retrieve the class by `class_id`. - The API returns no aggregated revenue figures. Compute revenue from invoices and invoice items in your own store. # Website schedule embed Use this guide when your goal is to display live class schedules, appointments, venues, or teacher information on an external website. ## Who this is for - Companies that want to show their timetable on their own website without using the bsport widget. - Development teams building a custom booking or discovery experience on top of bsport schedule data. ## What you can do Four read endpoints provide structured access to schedule data: | Endpoint | Description | | -------------------------------------- | --------------------------------------------------- | | `GET /api/v2/management/classes/` | List class sessions with dates, times, and capacity | | `GET /api/v2/management/appointments/` | List booked appointments (not free time slots) | | `GET /api/v2/management/venues/` | List venue details (name, address, location) | | `GET /api/v2/management/teachers/` | List teacher profiles (name, bio, photo) | The classes endpoint defaults to the next 30 days `GET /api/v2/management/classes/` filters on `starts_after` (defaults to now) and `starts_before` (defaults to now + 30 days). Omitting both returns only the next 30 days of classes. The example below passes both explicitly, which is what you want for a schedule embed. ## Recommended architecture: scheduled cache refresh Fetch schedule data on your server side and serve it from your own cache. Refresh on a regular interval. ```text Website visitor request -> Your backend (cached schedule data) -> Rendered schedule page Background job (every 15-60 min) -> Public API: classes, appointments, venues, teachers -> Update cache ``` Never call the API from client-side JavaScript Calling the API directly from the browser exposes your API key to visitors. Always proxy requests through your backend. ```python import requests import time from datetime import datetime, timedelta, timezone # YOUR_ENV_DOMAIN: public.production.bsport.io BASE_URL = "https://YOUR_ENV_DOMAIN" HEADERS = { "X-Api-Key": "YOUR_API_KEY", "X-Client-ID": "YOUR_CLIENT_ID", "X-Company-ID": "YOUR_COMPANY_ID", } def fetch_all(path: str, extra_params: dict = None) -> list: results = [] page = 1 while True: params = {"page_size": 100, "page": page, **(extra_params or {})} response = requests.get(f"{BASE_URL}{path}", headers=HEADERS, params=params) response.raise_for_status() data = response.json() results.extend(data["results"]) page = data["next_page"] if page is None: break time.sleep(0.3) # stay within rate limit return results def build_schedule_cache() -> list: today = datetime.now(timezone.utc) next_week = today + timedelta(days=7) venues = {v["id"]: v for v in fetch_all("/api/v2/management/venues/")} teachers = {t["id"]: t for t in fetch_all("/api/v2/management/teachers/")} classes = fetch_all( "/api/v2/management/classes/", extra_params={ "starts_after": today.isoformat(), "starts_before": next_week.isoformat(), }, ) for cls in classes: cls["venue"] = venues.get(cls.get("venue_id")) cls["teacher"] = teachers.get(cls.get("teacher_id")) return classes schedule = build_schedule_cache() # Store the schedule in your backend cache. ``` ## Webhook alternative: event-driven cache invalidation Use V2 class webhooks to invalidate and refresh your cache as soon as a class changes, instead of waiting for the next scheduled refresh. ```text Public API event (class.created or class.updated) -> your webhook endpoint -> trigger build_schedule_cache() -> update cache ``` ```python from flask import Flask, request, jsonify app = Flask(__name__) @app.route("/webhook/bsport", methods=["POST"]) def handle_bsport_event(): raw_body = request.get_data() verify_bsport_signature(raw_body, request.headers["Bsport-Signature"]) payload = request.get_json() event_type = payload["event_type"] if event_type in ("class.created", "class.updated"): schedule = build_schedule_cache() store_in_cache(schedule) return jsonify({"status": "accepted"}), 200 ``` `verify_bsport_signature` is defined in [Delivery, signatures and retries](https://api-docs.production.bsport.io/webhooks/04-delivery.html#verify-the-signature). The event `data` object is the current Class resource. See the [event catalogue](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html) for the complete payload schema. ## API key scope For a single-company website, use a Company API key scoped to that company. Do not use a Franchisor API key for a single-company embed as it grants broader access than needed. See [Headers and tenant context](https://api-docs.production.bsport.io/guides/01-authentication.html#tenant-and-client-headers). ## Limitations Automate bookings for your company The booking endpoints are intended for your company team's workflows and third-party automation tools, not for client-facing booking interfaces. You cannot accept client bookings directly through the Public API. **Client booking:** If your website needs to accept client bookings, you have two options: 1. **Embed the bsport widget** - use the turnkey bsport booking widget 1. **Contact bsport** - discuss custom booking solutions with your account manager **Schedule display:** You can freely display class schedules, capacity, and availability using the read-only endpoints documented above. **Capacity and waitlist data:** Classes expose `current_bookings`, `max_capacity`, `max_waitlist_size` and `current_waitlist_size`. Appointments represent existing private bookings and do not expose these capacity or waitlist counters. Appointment slots describe duration and credit cost, not free time windows. Check the API reference for each endpoint to confirm which fields are available. # AI and automation bsport + Model Context Protocol # Let your AI assistant work with bsport Connect a compatible AI assistant to the bsport Public API. Look up operational information, prepare day-to-day work, and change records through a conversation, while bsport limits access to your authorized companies. [Connect an assistant](https://api-docs.production.bsport.io/guides/09-connect-ai-assistants-with-mcp.html) [Explore API V2](https://api-docs.production.bsport.io/reference/01-scalar-v2.html) Who this page is for, and what it covers This page is for your company or franchise team to work through an AI assistant. It covers what the MCP server exposes, what you need before connecting, and which assistants are supported. If you are building a server-to-server integration, use the Public API directly with an API key instead: start at [Getting started](https://api-docs.production.bsport.io/guides/00-getting-started.html). If you want to use an LLM to help you write that integration, see [Using LLMs for integrations](https://api-docs.production.bsport.io/guides/05-using-llms-for-integrations.html). ## What you can do Read ### Find the right operational context List and open clients, bookings, classes, appointments, passes, client passes, subscriptions, client subscriptions, teachers, venues, tags, tag groups, client notes, and webhook registrations. Manage ### Act on day-to-day requests Create clients and bookings, cancel a booking, record attendance, archive a client, tag and untag a client, enable or disable a client pass, add a note, create tags, tag groups and venues, and update existing webhook registrations. Control ### See what a tool will do before it runs Every tool declares its impact as read-only, additive, or consequential, so your assistant can tell you which calls change a bsport record and ask first. Typical uses include checking tomorrow's schedule, finding a client's current passes, preparing a booking change, adding an internal note, or organizing clients with tags. ### What each resource allows Read the table by resource: the **Read** column is available on every resource, and the **Change** column lists the actions the server exposes. A resource marked read-only has no write tool at all, so an assistant cannot create or edit it. | Resource | Read | Change | | --------------------- | ---------- | --------------------------------- | | Bookings | List, open | Create, cancel, record attendance | | Clients | List, open | Create, archive, tag, untag | | Client passes | List, open | Enable, disable | | Client notes | List, open | Create | | Tags | List, open | Create | | Tag groups | List, open | Create | | Venues | List, open | Create | | Webhook registrations | List, open | Create, update | | Appointments | List, open | Read-only | | Classes | List, open | Read-only | | Passes | List, open | Read-only | | Subscriptions | List, open | Read-only | | Client subscriptions | List, open | Read-only | | Teachers | List, open | Read-only | A pass is a product that can be purchased and a client pass is a pass owned by a client; the same split applies to subscriptions and client subscriptions. See [Terminology](https://api-docs.production.bsport.io/guides/08-terminology.html) for the full resource naming rules. MCP uses Public API V2. Create V2 webhook registrations through MCP or the [V2 REST endpoint](https://api-docs.production.bsport.io/webhooks/01-public-api-webhooks.html). Updating an existing registration preserves its payload version, including historical V1 registrations. ## Before you connect You need a bsport company or franchise account with the Owner or Admin role, on a plan that includes MCP. Other staff roles cannot connect, even if the plan includes MCP. The bsport team also has to grant MCP access. Access is granted to the user account, not to the company, so a colleague cannot connect until their own account is granted. To request access, see [MCP support](https://api-docs.production.bsport.io/guides/mcp-support.html). Your plan sets what the assistant can do: read data, or read and change it. A franchise account gets the best plan across the companies it can access. When your plan includes changes and your assistant requests them, you choose on the bsport page whether to allow them for this connection. Read access is always included. You also need an assistant that supports remote MCP servers over: - Streamable HTTP - OAuth authorization-code authentication with PKCE - Dynamic client registration The production server URL is: ```text https://public.production.bsport.io/mcp ``` Authentication happens in your browser through your bsport account. No extra technical configuration is needed. For a franchise account, ask for the company by name. Your assistant can discover the companies you are authorized to access and choose the requested one. If the name is ambiguous, it should ask you to clarify before acting. Accounts attached to a particular company keep that company's scope, including accounts that also have a franchise role. bsport requests two scopes during authorization: `mcp:read` covers the tools that list and open records, and `mcp:manage` covers every tool that changes one. Your assistant sees only the tools its granted scopes allow. Data you retrieve leaves bsport Information returned by bsport tools is shared with the AI provider under that provider's terms and controls. Do not use MCP to move client data into an assistant your company has not approved for it. Approve changes deliberately Tools that change a bsport record are annotated as consequential. Review the target, the inputs, and the intended outcome before you approve one. ### Limits List tools return at most 100 records per call and default to 50, the same limits as the Public API endpoints they wrap. MCP tool calls go through the same Public API rate limits as a direct REST integration, so a long conversation can trigger a `429`: see [Rate limits](https://api-docs.production.bsport.io/guides/06-rate-limits.html). ## Compatible assistants Setup instructions are available for: - ChatGPT - Claude and Claude Code - Cursor - Gemini CLI Any other assistant that meets the three requirements above can connect through dynamic client registration. The [connection guide](https://api-docs.production.bsport.io/guides/09-connect-ai-assistants-with-mcp.html) has the per-assistant steps and troubleshooting advice. ## Example conversation ```text You: Use bsport to find tomorrow morning's classes at the central venue. Assistant: I found three classes. Do you want their current booking counts too? You: Yes, then show me the clients booked into the 09:00 class. ``` The assistant discovers the relevant bsport tools and resolves the records itself. Before a change, ask it to state the exact target and action so you can check both before approving the tool call. ## Get help For connection problems, access requests, or unexpected tool results, see [MCP support](https://api-docs.production.bsport.io/guides/mcp-support.html). It lists the support and security contacts and bsport's privacy and legal pages. Ready to connect? ## Set up bsport in your AI assistant Follow the per-assistant guide, or review the complete Public API V2 contract first. [Open the connection guide](https://api-docs.production.bsport.io/guides/09-connect-ai-assistants-with-mcp.html) [Open API reference V2](https://api-docs.production.bsport.io/reference/01-scalar-v2.html) # Connect an AI assistant with MCP The bsport MCP server lets a compatible AI assistant use selected Public API operations as tools. The assistant can discover an operation, ask for its inputs, and call it without you copying API schemas or writing HTTP requests. For an overview of capabilities, access requirements, and compatible assistants, start with the [MCP overview](https://api-docs.production.bsport.io/guides/mcp.html). This guide contains the detailed setup steps for each client. [Model Context Protocol (MCP)](https://modelcontextprotocol.io/docs/getting-started/intro) is an open standard for connecting AI applications to tools and data. The bsport server covers management operations available through the Public API. For the authoritative and current coverage, use the [API reference V2](https://api-docs.production.bsport.io/reference/01-scalar-v2.html) instead of relying on a fixed tool list in this guide. MCP tools are generated from the V2 management operations. Review actions before approving them MCP tools can read or change bsport data. Check the inputs and requested action before approving a tool call. Data returned by a tool is also shared with the AI provider under that provider's terms. ## Before you connect You need: - A bsport company or franchise account with the Owner or Admin role, on a plan that includes MCP. - Production MCP access granted to that account by the bsport team. Access is granted to the user account, not to every user in a company. - An AI client that supports remote MCP servers over Streamable HTTP, OAuth authorization-code authentication with PKCE, and dynamic client registration. The production MCP server URL is: ```text https://public.production.bsport.io/mcp ``` MCP authentication uses your bsport account through OAuth. Do not enter a Public API key, OAuth client ID, or OAuth client secret. Compatible clients register themselves and open the bsport sign-in page in your browser. ## ChatGPT 1. In ChatGPT, open **Settings > Security and login** and enable **Developer mode**. 1. Open [ChatGPT Plugins](https://chatgpt.com/plugins), select the plus button, and create a developer-mode app. 1. Give the app a name such as `bsport`, then enter the production MCP server URL above. 1. Complete the bsport sign-in and authorization flow in your browser. 1. In a conversation, open the plus menu, choose **Developer mode**, and enable the bsport app. See OpenAI's [ChatGPT Developer mode guide](https://developers.openai.com/api/docs/guides/developer-mode) for current availability, controls, and UI details. ## Claude 1. In Claude, open **Customize > Connectors**. 1. Select **+**, then **Add custom connector**. 1. Enter a name such as `bsport` and the production MCP server URL above. Leave the optional OAuth client ID and client secret empty. 1. Complete the bsport sign-in and authorization flow. 1. In a conversation, use **+ > Connectors** to enable the bsport connector. For Team and Enterprise plans, an Owner must first add the connector under **Organization settings > Connectors**. Each user then connects their own bsport account. See Anthropic's [remote MCP connector guide](https://support.claude.com/en/articles/11175166-get-started-with-custom-connectors-using-remote-mcp) for plan-specific instructions. ## Claude Code Add the server from a terminal: ```bash claude mcp add --transport http bsport https://public.production.bsport.io/mcp ``` Start Claude Code, run `/mcp`, select `bsport`, and complete authentication in your browser. See the [Claude Code MCP documentation](https://code.claude.com/docs/en/mcp) for configuration scopes and management commands. ## Cursor Add the following server to your project or user MCP configuration: ```json { "mcpServers": { "bsport": { "url": "https://public.production.bsport.io/mcp" } } } ``` Open Cursor's **Customize** page, enable the `bsport` server, and complete OAuth in your browser. See the [Cursor MCP documentation](https://cursor.com/docs/mcp) for configuration locations and server controls. ## Gemini CLI Add the server from a terminal: ```bash gemini mcp add --transport http bsport https://public.production.bsport.io/mcp ``` In Gemini CLI, run `/mcp auth bsport` and complete authentication in your browser. See the [Gemini CLI MCP documentation](https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/mcp-server.md) for more configuration options. ## Other MCP clients Use the production server URL with the client's remote or HTTP transport. The client must support OAuth authorization-code authentication with PKCE and dynamic client registration. Some clients display optional OAuth client ID and client secret fields; leave them blank. A client is incompatible with the bsport server only if it requires pre-registered credentials and cannot perform dynamic client registration. ## Start a conversation Tell the assistant what you want to do: ```text Use bsport to list tomorrow's bookings. ``` For a franchise account, ask for the company by name: for example, "Show tomorrow's classes for Kaizen Lyon." Your assistant can discover the companies you can access and select the right one. If several companies match, it should ask you to clarify before taking action. You do not need a separate connection for each company. Accounts attached to a particular company keep access to that company, including accounts that also have a franchise role. bsport publishes its catalog through standard MCP tool discovery; it does not need a separate server-side tool search endpoint. Some clients load all tool descriptions immediately, while others load them only when needed. Claude Code, for example, enables tool search by default and loads matching definitions on demand. This behavior is controlled by the AI client. You can disable tools you do not need when your client provides tool controls. ## Troubleshooting - **Access is denied during sign-in:** read the reason on the bsport page. Only Owners and Admins can connect, your plan has to include MCP, and the bsport team has to have granted MCP access to your account. - **The assistant can't change data:** your connection is read-only. Disconnect, reconnect, and select **Manage bsport data** on the bsport page. The option appears when your plan includes it and your assistant requests write access. - **The assistant asks which company to use:** give the company name. The assistant can find it among your accessible companies; you do not need to look up its ID. - **The server does not connect:** confirm that the client supports remote MCP, Streamable HTTP, OAuth authorization-code with PKCE, and dynamic client registration. Organization policies can also prevent users from adding custom connectors. - **Tools look out of date:** refresh or reconnect the server in the client's MCP settings. If these steps do not solve it, see [MCP support](https://api-docs.production.bsport.io/guides/mcp-support.html). Return to the [MCP overview](https://api-docs.production.bsport.io/guides/mcp.html), or explore the complete [API reference V2](https://api-docs.production.bsport.io/reference/01-scalar-v2.html). # MCP support Use this page to get help with the bsport MCP server, report a security issue, or find bsport's privacy and legal pages. It is for company and franchise teams that connect an AI assistant to bsport. For setup steps, see [Connect an AI assistant with MCP](https://api-docs.production.bsport.io/guides/09-connect-ai-assistants-with-mcp.html). For what the server can do, see the [MCP overview](https://api-docs.production.bsport.io/guides/mcp.html). ## Contact bsport Read the table by topic, then use the address or link in the second column. | Topic | Where to go | | --------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | | Connection problems, access requests, unexpected results from a bsport tool | [support@bsport.io](mailto:support@bsport.io) | | A security issue or vulnerability | [security@bsport.io](mailto:security@bsport.io). See the [security policy](https://pro.bsport.io/security-policy) | | Questions about personal data | [privacy@bsport.io](mailto:privacy@bsport.io) | ## What support covers bsport supports the connection to bsport and the bsport tools: sign-in and access, what the server exposes, and the results of a tool call. The assistant itself (its settings, plan, limits and answers) belongs to its provider, such as OpenAI or Anthropic. Contact that provider for those questions. ## What to send Include: - The assistant you use (ChatGPT, Claude, or another) and the date and time of the problem. - The name of your company or franchise. - What you asked, and what went wrong. - The tool name or the error message, if the assistant showed one. Do not include client names, email addresses, or other personal data. ## Common questions Read the table by question. Each answer points to the page that holds the details. | Question | Answer | | ------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | I cannot connect. | Check the access rules in [Before you connect](https://api-docs.production.bsport.io/guides/mcp.html#before-you-connect). To request access, see [Contact bsport](#contact-bsport). | | The assistant cannot change data. | Your connection is read-only. See [Troubleshooting](https://api-docs.production.bsport.io/guides/09-connect-ai-assistants-with-mcp.html#troubleshooting). | | The assistant cannot see a company. | It sees only the companies your account is authorized to access. Ask for the company by name. | | The assistant did something I did not want. | Disconnect bsport in your assistant's connector settings, check the affected records in bsport, then write to support. | | How do I disconnect? | Remove the bsport connector in your assistant's connector settings. | Information returned by bsport tools is shared with your AI provider under that provider's terms. See [Before you connect](https://api-docs.production.bsport.io/guides/mcp.html#before-you-connect). ## Report a security issue Report security issues privately Email [security@bsport.io](mailto:security@bsport.io) with the subject "MCP security". Do not post details in public. See the [security policy](https://pro.bsport.io/security-policy). ## Privacy and legal Read the table by what you need. | Need | Link | | -------------------------------- | ---------------------------------------------------------------------- | | Privacy policy | [pro.bsport.io/privacy](https://pro.bsport.io/privacy) | | Legal identity and legal notices | [pro.bsport.io/legal](https://pro.bsport.io/legal) | | Security policy | [pro.bsport.io/security-policy](https://pro.bsport.io/security-policy) | # Using LLMs for custom integrations Large language models (LLMs) like ChatGPT, Claude, or Gemini can help your team build Public API integrations faster. Use them to plan, draft requests and generate automation steps, then validate every output before going live. Who this page is for This page is for developers and automation builders who write a REST integration with an LLM's help. To let an assistant work with the records of your own company or franchise team, see the [MCP overview](https://api-docs.production.bsport.io/guides/mcp.html). To learn the API itself, start with [Getting started](https://api-docs.production.bsport.io/guides/00-getting-started.html). ## Security rules to follow Never share secrets or sensitive data in prompts Do not paste production API keys, client personal data, payment data, or internal identifiers into ChatGPT, Claude, Gemini, or any other external AI tool. **Before using an LLM**: - Use placeholder values like `YOUR_API_KEY` instead of real credentials. - Remove or anonymize personal or sensitive information and payment-related fields. - Share only the minimum context needed to get useful help. - Review your company AI policy and compliance requirements. The documentation pages and OpenAPI files are public: share them freely. ## Give the LLM the right sources An LLM that answers from memory often returns V1 paths or outdated field names. Give it the current sources below. Read the table by source. Each row says what it settles. | Source | Use it for | | ------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [openapi-v2.yml](https://api-docs.production.bsport.io/schemas/openapi-v2.yml) | Endpoints, fields, filters and the status codes each operation declares. This is the source of truth. The file is close to 1 MB, over 250,000 tokens. | | [llms.txt](https://api-docs.production.bsport.io/llms.txt) | An index of the guides for assistants that can fetch web pages: authentication, pagination, errors, rate limits, task guides, webhooks and the changelog. Each guide also has a Markdown version: replace `.html` with `.md` in its URL. | | [llms-full.txt](https://api-docs.production.bsport.io/llms-full.txt) | The full text of those guides in one file of about 230 KB, for an assistant that cannot fetch several pages. | The OpenAPI file decides endpoints, fields and filters. The guides decide behavior the file does not describe, such as tenant headers, pagination, retries and the side effects of writes. The [changelog](https://api-docs.production.bsport.io/changelog/index.html) lists renamed fields. Use `openapi-v2.yml` only. V1 retires on January 15, 2027: see [Migrate from V1 to V2](https://api-docs.production.bsport.io/guides/11-migrate-from-v1-to-v2.html). ## Prompt workflow **Use this workflow**: 1. Download `openapi-v2.yml` from the [API reference](https://api-docs.production.bsport.io/reference/01-scalar-v2.html). Give it to a coding assistant that reads files from your project, or to a tool that searches attached files. A chat that loads an attached file whole cannot hold it: paste the operations you need from the API reference instead. 1. Give the assistant the `llms.txt` URL, or attach `llms-full.txt` if it cannot fetch pages. 1. Use the baseline prompt below and adapt it to your endpoint and goal. ### Baseline prompt template (copy/paste) ```text You are an integration engineer helping me build a bsport Public API integration. Source of truth: - Use the attached V2 OpenAPI file for endpoints, fields and filters. - Use the bsport guides I provide for authentication, pagination and errors. - Use only /api/v2/ paths. Do not rely on memory or guesses. Safety: - Use placeholders only (no real API key, personal data or payment data). Missing info rule: - If anything is missing or ambiguous, do not guess. Return what is missing, where it is needed, and what I should provide next. Return: 1) Step-by-step setup (Make and/or n8n if relevant) 2) Example HTTP request (URL, headers, query params, body) 3) Basic error handling (at least 401, 403, 429, 500 when applicable) 4) Test checklist ``` ### Example: Build a ping Prompt (copy/paste): ```text You are an integration engineer helping me build a bsport Public API integration. Source of truth: - Use the attached V2 OpenAPI file for endpoints, fields and filters. - Use the bsport guides I provide for authentication, pagination and errors. - Use only /api/v2/ paths. Do not rely on memory or guesses. Safety: - Use placeholders only (no real API key, personal data or payment data). Missing info rule: - If anything is missing or ambiguous, do not guess. Return what is missing, where it is needed, and what I should provide next. Task: - Tool: [YOUR_TOOL] (Make scenario or n8n workflow) - Endpoint: GET /api/v2/monitoring/health/ping/ - Include the required headers from the spec (placeholders for values). - Add a success branch (200), a failure branch (401/403) and handling for 429 and 500. Return: 1) Exact module-by-module (Make) or node-by-node (n8n) steps 2) Request configuration (method, URL, headers) 3) Test checklist ``` Typical result you should expect: - A `GET` request (a Make HTTP module or an n8n `HTTP Request` node) with these headers as placeholders: - `X-Api-Key: YOUR_API_KEY` - `X-Client-ID: YOUR_CLIENT_ID` - `X-Company-ID: YOUR_COMPANY_ID` with a company API key, or `X-Franchisor-ID: YOUR_FRANCHISOR_ID` with a franchise API key - A success path for `200`, a failure path for `401/403` (an n8n `IF` node or a Make router), and retry handling for `429` and `500`. ## LLM prompt cookbook Use these ready-to-copy prompts for common integration tasks. Each prompt keeps the same rule: OpenAPI file first, placeholders only. Name the tool in the `Tool:` line: Make (modules, routers, error branches), n8n (nodes, IF, retries) or custom code (Python, Node.js, etc). ### 1. Create a client ```text You are an integration engineer helping me build a bsport Public API integration. Source of truth: - Use the attached V2 OpenAPI file for endpoints, fields and filters. - Use the bsport guides I provide for authentication, pagination and errors. - Use only /api/v2/ paths. Do not rely on memory or guesses. Safety: - Use placeholders only (no real API key, personal data or payment data). Missing info rule: - If anything is missing or ambiguous, do not guess. Return what is missing, where it is needed, and what I should provide next. Task: - Tool: [YOUR_TOOL] (Make, n8n, or custom code) - Endpoint: POST /api/v2/management/clients/ Return: 1) Required fields checklist 2) Example HTTP request with placeholders 3) Tool-specific implementation for [YOUR_TOOL] 4) Validation checklist before production ``` **Expected output**: - A field checklist and a request example with placeholder headers and payload values. - A warning that the call is not idempotent: after a timeout, look the client up by email before you retry. - A setup or runnable code matching `Tool: [YOUR_TOOL]`. ### 2. List bookings with filters ```text You are an integration engineer helping me build a bsport Public API integration. Source of truth: - Use the attached V2 OpenAPI file for endpoints, fields and filters. - Use the bsport guides I provide for authentication, pagination and errors. - Use only /api/v2/ paths. Do not rely on memory or guesses. Safety: - Use placeholders only (no real API key, personal data or payment data). Missing info rule: - If anything is missing or ambiguous, do not guess. Return what is missing, where it is needed, and what I should provide next. Task: - Tool: [YOUR_TOOL] (Make, n8n, or custom code) - Goal: list the bookings of one client for a date range and a booking status - Endpoint: GET /api/v2/management/bookings/ Return: 1) Query parameters to use 2) Example request URL and headers 3) How to handle pagination safely 4) Tool-specific implementation for [YOUR_TOOL] (including pagination) ``` **Expected output**: - The filters from the schema: `client_id`, `class_start_after`, `class_start_before` and `booking_status_code`. - Pagination logic that sends `page` until `next_page` is `null`. - A setup or runnable code matching `Tool: [YOUR_TOOL]`. ### 3. Handle `401` and `403` ```text You are an integration engineer helping me build a bsport Public API integration. Source of truth: - Use the attached V2 OpenAPI file for endpoints, fields and filters. - Use the bsport guides I provide for authentication, pagination and errors. - Use only /api/v2/ paths. Do not rely on memory or guesses. Safety: - Use placeholders only (no real API key, personal data or payment data). Missing info rule: - If anything is missing or ambiguous, do not guess. Return what is missing, where it is needed, and what I should provide next. Task: - Tool: [YOUR_TOOL] (Make, n8n, or custom code) - Design error handling for auth errors (401 and 403) - Example endpoint: GET /api/v2/monitoring/health/ping/ Return: 1) Decision tree for 401 vs 403 2) Operator actions for each error 3) Tool-specific implementation for [YOUR_TOOL] 4) Alert message templates without sensitive data ``` **Expected output**: - A decision flow that separates a rejected API key (`401`) from a missing key or a tenant context the key cannot act on (`403`). Compare it with [Errors and status codes](https://api-docs.production.bsport.io/guides/04-errors-and-statuses.html). - Operator actions: check the key, the tenant headers and the access scope. - Alert templates that do not expose secrets or client data. ## Human validation checklist Before moving to production: - Replace placeholders only inside your secure environment. - Confirm the required headers are present: `X-Api-Key`, `X-Client-ID` and a tenant header. - Confirm every path starts with `/api/v2/`. - Start with read requests: an API key acts on live data. See [Base URL](https://api-docs.production.bsport.io/guides/00-getting-started.html#base-url). - Validate failure behavior for `401`, `403`, `429`, and `500`. The V2 OpenAPI file declares `401`, `403` and `429` on every operation but `500` on only a few, so handle `500` on every call. See [Retries](https://api-docs.production.bsport.io/guides/04-errors-and-statuses.html#retries) for reads and writes. - Keep logs and monitoring enabled for the new workflow. ## Common mistakes - Asking the LLM to "use my real key from this message". - Pasting real client records into a prompt for troubleshooting. - Deploying generated workflows without manual review. - Accepting V1 names in generated code, such as `/api/v1/` paths, `session_id`, `period_start` or `base_price`. The renames are in [Migrate from V1 to V2](https://api-docs.production.bsport.io/guides/11-migrate-from-v1-to-v2.html) and the [changelog](https://api-docs.production.bsport.io/changelog/index.html). - Loading the whole OpenAPI file into a chat that cannot hold it. ## Next step After your ping works, ask the LLM for one endpoint at a time and review each generated step against your security and QA process. # Changelog # API V2 is available V2 is a separate contract under `/api/v2/`. It adds endpoints for scheduling, catalogue, finance and messaging, and uses consistent field names. V1 keeps working until January 15, 2027. New integrations use V2: see [Getting started](https://api-docs.production.bsport.io/guides/00-getting-started.html). Existing integrations follow [Migrate from V1 to V2](https://api-docs.production.bsport.io/guides/11-migrate-from-v1-to-v2.html). Migration is not only a URL change On classes, `service_id` and `teacher_id` keep their names but identify different records in V2. Requests still return `200`, so a stored V1 ID can match the wrong class. Reload your service and teacher mappings before you switch. **New operations in V2.** All paths are under `/api/v2/management/`. Read the table by area. | Area | Operations | | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Classes | `POST /classes/`, `PATCH /classes/{id}/`, `POST /classes/{id}/cancel/`, `GET /classes/{id}/spots/`, `GET /classes/{id}/waitlist/` | | Appointments | `POST /appointments/`, `POST /appointments/{id}/cancel/`, read `/appointment-services/` and `/appointment-slots/` | | Services and levels | Read `/services/` and `/levels/`. They resolve the `service_id` and `level_id` values on classes | | Venues and teachers | `PATCH /venues/{id}/`, `POST` and `PATCH /teachers/{id}/pay-rates/`, read `/teacher-pay-rates/` | | Clients | `PATCH /clients/{id}/`. `PATCH` and `DELETE` on `/client-notes/{id}/`, `/tags/{id}/` and `/tag-groups/{id}/` | | Passes | `/class-passes/`, `/client-class-passes/` with enable and disable, `/appointment-passes/`, `/client-appointment-passes/` with `PATCH` and disable | | Retail and promotions | `/products/`, `/coupons/` (discount codes), `/coupon-usages/` (read only), `/gift-cards/`. State changes use dedicated actions: enable and disable for products and gift cards, disable only for discount codes | | Finance | Read `/invoices/` and `/invoice-items/` | | Communications | `POST /communications/` to queue an email or SMS, `GET /communications/` and `GET /communications/{id}/` for processing status | **Expand related resources.** Supported list and detail endpoints accept repeatable `expand[]` query parameters. Expandable ID fields are replaced in place by the related resource, with dot notation for up to two levels. See [Pagination and filtering](https://api-docs.production.bsport.io/guides/03-pagination-and-filtering.html#expanding-related-resources). **What changes from V1.** The migration guide has every table. The main changes: - `/passes/` and `/client-passes/` become `/class-passes/` and `/client-class-passes/`. V2 has no aliases for the old paths. - Spelling and naming are consistent: `is_canceled`, `cancelable_until`, `current_waitlist_size`, `is_bookable_by_clients`, `venue_id`, `firstname`, `lastname` and `phone_number`. - Bookings use `class_id`, `class_ids` and `client_class_pass_id`. The `session_*`, `location_id` and `client_pass_id` names are not exposed. - Client creation takes `client_reference` instead of `membership`, and tag creation requires a `color`. - Subscriptions use `subscription_template_id`, `subscription_terms` and the `class_pass` benefit type. For side effects of writes, such as clearing a substitute teacher or disabling a product, read [V2 workflows and field conventions](https://api-docs.production.bsport.io/guides/10-v2-workflows.html). **MCP and webhooks.** MCP tools are generated from the V2 operations, with V2 field names and IDs. Webhook payloads depend on the registration. New registrations are always created through V2 and deliver V2 payloads with canonical event names. Existing registrations keep delivering V1 payloads and historical event names, and do not change. To move an event to V2 payloads, create a new registration for it and disable the old one. See [Webhook event payloads](https://api-docs.production.bsport.io/webhooks/05-event-payloads.html#payload-versions) and the [migration guide](https://api-docs.production.bsport.io/guides/11-migrate-from-v1-to-v2.html#webhooks-and-mcp). **Sunset dates.** Read the table by route group. | Routes | Replacement | Removal date | | ---------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | ----------------- | | Legacy V1 routes: `bookings`, `members`, `contracts`, `billing_plans`, `payment_packs`, `consumer_payment_packs` | See the replacements in [Deprecated legacy routes](https://api-docs.production.bsport.io/changelog/deprecated-legacy-routes.html) | November 30, 2026 | | All other V1 routes | The V2 endpoint listed in the [migration guide](https://api-docs.production.bsport.io/guides/11-migrate-from-v1-to-v2.html) | January 15, 2027 | # Appointment, service, and venue webhooks (V2 only) The V2 catalogue adds appointment creation, updates and cancellation transitions; service creation and updates; and venue creation, updates and removal from a company's catalogue. Current-state payloads use the same unexpanded representation as the corresponding V2 REST endpoint. `venue.deleted` contains only the venue ID and does not imply global venue deletion. Existing V1 registrations retain their original contracts; new V1 registrations remain retired. V2 appointments whose client is no longer addressable are omitted from lists, return 404 on retrieval, and are not delivered by webhook. Membership-plan and billing-plan events are not part of this catalogue. # Back Office webhook reference published (legacy) The first webhook articles documented registrations configured in Back Office under `Settings > Webhook`. Those webhooks use the legacy registration system and payloads: - Member webhook (`member-create`, `member-update`) - Booking webhook (`booking-create`, `booking-update`, `booking-delete`) - Billing plan webhook (`billing_plan-create`, `billing_plan-update`) - Offer webhook (`offer-create`, `offer-update`) - Coach webhook (`associated_coach-create`, `associated_coach-update`, `associated_coach-delete`) - Invoice webhook (`invoice-finalize`, `invoice-pay`) - Tag webhook (`tag-create`, `tag-update`, `tag-delete`) These are not the current Public API webhook contract. New integrations must use registrations created through the Public API and the [current event catalogue](https://api-docs.production.bsport.io/webhooks/02-public-api-event-reference.html). # Bookings updates Enhanced bookings endpoint: - `GET /api/v1/management/bookings/` - List bookings with client context - Permission-based access control: only view bookings for your clients - `client_id` filter to list the bookings of one client # Change the credits and validity of a client class pass `PATCH /api/v2/management/client-class-passes/{id}/` sets the credits left on a client class pass with `available_credits_amount` and extends its validity with `additional_validity_days`, like client appointment passes. Credits cannot change on an unlimited or refunded pass, a copy of another pass, or a pass that also covers appointments (CCP-103), and a copy shared from a related client cannot be extended (CCP-104). Client class passes now also return `validity_extension_days`, the total days added by extensions, in responses and in the `client_class_pass.created` and `client_class_pass.updated` webhook payloads. # Class pass and product webhooks (V2 only) New V2 registrations can subscribe to `class_pass.created`, `class_pass.updated`, `client_class_pass.created`, `client_class_pass.updated`, `product.created`, and `product.updated`. Deliveries use the corresponding unexpanded V2 REST resource. V2 client class passes require a client in the class pass owner's company. Passes without that client are omitted from lists, return 404 for detail requests, and skip webhook delivery. Their underlying pass and V1 behavior are unchanged. Updates cover related data as well as the resource row and can repeat an unchanged current representation. Treat them as refresh notifications, not incremental credit or stock movements. These events do not confirm payment or emit expiration transitions from the clock. Existing V1 registrations keep their historical catalogue. See [the resource mapping](https://api-docs.production.bsport.io/webhooks/05-event-payloads.html). # Deprecated legacy routes The legacy V1 routes outside `/api/v1/management/` are deprecated. Updated in October 2026: the removal date is November 30, 2026, and the list covers all six route groups, not only `bookings` and `consumer_payment_packs`. | Deprecated route | Replacement | | --------------------------------- | -------------------------------------------------------------------------------------------------- | | `/api/v1/bookings/` | `/api/v1/management/bookings/` (V1) or `/api/v2/management/bookings/` (V2) | | `/api/v1/consumer_payment_packs/` | `/api/v1/management/client-passes/` (V1) or `/api/v2/management/client-class-passes/` (V2) | | `/api/v1/payment_packs/` | `/api/v1/management/client-passes/` (V1) or `/api/v2/management/client-class-passes/` (V2) | | `/api/v1/members/` | `/api/v1/management/clients/` (V1) or `/api/v2/management/clients/` (V2) | | `/api/v1/contracts/` | `/api/v1/management/subscriptions/` (V1) or `/api/v2/management/subscriptions/` (V2) | | `/api/v1/billing_plans/` | `/api/v1/management/client-subscriptions/` (V1) or `/api/v2/management/client-subscriptions/` (V2) | The management endpoints return the same core data with consistent pagination, filtering, and identifier alignment with the rest of the Public API. Removal date: November 30, 2026 These paths stop working after November 30, 2026. If your integration still calls them, migrate before that date. Migration steps: 1. Replace the path in your HTTP client. 1. Verify that response field names match your downstream mapping (field names may differ between the old and new endpoints). 1. Re-run your integration tests against the new paths. # Initial Public API release Core endpoints for reading and creating data: **Client management**: - `POST /api/v1/clients/` - Create client records - `GET /api/v1/clients/` - List clients with filtering and pagination - `GET /api/v1/clients/{id}/` - Retrieve individual client details **Bookings**: - `POST /api/v1/bookings/` - Create bookings - `GET /api/v1/bookings/` - List bookings **Passes and subscriptions**: - `GET /api/v1/client-passes/` - List client passes (purchase history) - `GET /api/v1/client-subscriptions/` - List client subscriptions - `GET /api/v1/contracts/` - List subscription contract products - `GET /api/v1/passes/` - List pass products **Authentication**: - API key authentication with `X-Api-Key`, `X-Client-ID`, `X-Company-ID` headers - Support for single company and franchise (multi-company) access **Documentation**: - OpenAPI specification with endpoint descriptions - Getting started guide - Authentication guide - Pagination and filtering reference # Invoice webhooks in V2 V2 registrations support `invoice.created` and `invoice.updated` with the same unexpanded Invoice representation as the V2 retrieve endpoint, including grouped `line_items`. Invoice-item creation, updates, and deletion also produce `invoice.updated`; reassignment can notify both invoices. These events report current state at delivery time, not payment lifecycle transitions. Existing V1 registrations and legacy Backoffice invoice payloads remain unchanged. See [Invoice events](https://api-docs.production.bsport.io/webhooks/invoice-webhook-v2.html) for trigger boundaries and migration guidance. # Management namespace and field renaming Launched the new `/api/v1/management/` namespace with standardized field names across all endpoints. **New endpoint paths** (April 1): - All core endpoints moved to `/api/v1/management/` (old paths deprecated but functional) - Consistent pagination, filtering, and response structure **Field name standardization** (April 1, 13): - Standardized all field names for consistency across the API - Examples: `date_*` -> `*_at`, boolean fields -> `is_*` prefix Applied to all endpoints: - Clients, bookings, billing plans, client subscriptions, client passes **Client subscriptions and billing plans** (April 16): - Updated field names and structure for clarity # MCP access follows your role and your plan Only Owners and Admins can connect an assistant to the bsport MCP server, and your plan sets what it can do: read data, or read and change it. When your plan includes changes and your assistant requests them, you choose whether to allow them when you connect. From its next token refresh, a connection that loses write access becomes read-only, and a connection that loses MCP access stops working. See [MCP overview](https://api-docs.production.bsport.io/guides/mcp.html). # New endpoints: classes, appointments, venues, and teachers Four read endpoints are now available, giving partners structured access to schedule data. | Endpoint | Description | | -------------------------------------- | ------------------------------------- | | `GET /api/v1/management/classes/` | List and retrieve class sessions | | `GET /api/v1/management/appointments/` | List and retrieve booked appointments | | `GET /api/v1/management/venues/` | List and retrieve venue information | | `GET /api/v1/management/teachers/` | List and retrieve teacher profiles | **Classes endpoint** (June 6): - Full list and detail views for group fitness sessions - Filters: `service_id`, `venue_id`, `teacher_id`, `period_start`, `period_end` - Renamed fields: `date_start` -> `starts_at`, `duration_minute` -> `duration_in_minutes`, `effectif` -> `max_capacity`, `validated_booking_count` -> `current_bookings`, `activity_id` -> `service_id` **Appointments endpoint** (June 3-4): - List and detail views for private 1-on-1 sessions - Service filter support **Venues endpoint** (May 13 - June): - List, retrieve, and create venues - Latitude and longitude validation - Timezone management per venue **Teachers endpoint** (May 27 - June): - List and detail views for instructor profiles - Filter by `is_disabled` - Teacher profile information (name, email, phone, bio, profile picture) **Client passes stability** (June 10-11): - Improved query performance for the `/client-passes/` endpoint - Better handling at scale ```text Large unfiltered result sets can still time out. See [Rate limits and bulk data sync](../../guides/06-rate-limits.md) for the filters to apply. ``` # Rate limiting All endpoints now enforce rate limiting: - **Limit**: 20 requests per second per company per endpoint - **Max page size**: 100 results per request - Applies to all public endpoints See [Rate limits and bulk data sync](https://api-docs.production.bsport.io/guides/06-rate-limits.html) for patterns on handling rate limits in bulk operations. # Rejected credentials return 401 An invalid, expired or revoked API key (the JWT sent in `X-Api-Key`) now returns `401` with an empty body and a `WWW-Authenticate: ApiKey` header, on V1 and V2. It previously returned `403` with `"Authentication credentials were not provided."`, the same response as a request without credentials. If your integration treats `403` as an invalid key, handle `401` as well. A request without credentials still returns `403`. See [Errors and status codes](https://api-docs.production.bsport.io/guides/04-errors-and-statuses.html). # See your API key and its usage `GET /api/v2/monitoring/me/` returns the API key making the call (`client_id`, company or franchise, `expires_at`) and its successful calls per UTC calendar month over the last 12 months. A franchise key also gets the calls made on each company of its franchise. See [Check your API key and usage](https://api-docs.production.bsport.io/guides/01-authentication.html#check-your-api-key-and-usage). From this release, a franchise-key call made on a company counts on that company as well as on the franchise. Company months before it leave out franchise-key calls. # Tag support Extended tagging to client records: - `POST /api/v1/management/clients/{id}/tag/` - Add a tag to a client - `POST /api/v1/management/clients/{id}/untag/` - Remove a tag from a client # Teacher endpoints Instructor management through the public API: - `GET /api/v1/management/teachers/` - List teachers with filtering options - `GET /api/v1/management/teachers/{id}/` - Retrieve individual teacher profile - Filter by `is_disabled` # Test deliveries and secret rotation for webhook registrations Two operations join the V2 Webhook Registrations endpoint: - `POST /api/v2/management/webhook-registrations/{id}/test/` sends one signed sample delivery to the registration's URL, once and without retry, and returns `is_delivered`, `http_status` and `failure_reason`. It works on inactive registrations and follows the registration's payload version. It is limited to 5 calls per minute per company. - `POST /api/v2/management/webhook-registrations/{id}/rotate-secret/` replaces the signing secret and returns the registration with its new `signing_secret`. The previous secret stops working at once. `signing_secret` now changes on rotation, and `updated_at` also records it. Registrations still cannot be deleted: send `is_active=false` to stop deliveries. See [Test a registration](https://api-docs.production.bsport.io/webhooks/01-public-api-webhooks.html#test-a-registration) and [Rotate the signing secret](https://api-docs.production.bsport.io/webhooks/04-delivery.html#rotate-the-signing-secret). # V2 booking date filters take a timestamp The bookings list filters now take the type of the field they filter, a timestamp: | Before | After | | --------------------------- | -------------------- | | `created_after_date` | `created_after` | | `created_before_date` | `created_before` | | `class_started_after_date` | `class_start_after` | | `class_started_before_date` | `class_start_before` | A plain date is still accepted, read as midnight in the company's time zone: `created_before=2026-03-11` now leaves out March 11, which `created_before_date=2026-03-11` included. Send `2026-03-11T23:59:59.999999` to keep the whole day. A request that still sends the old names is refused with `BSPORT-400`. This V2 change shipped before general availability, so it applies in place to V2 REST requests. V1 is unchanged. See [Dates, time zones and amounts](https://api-docs.production.bsport.io/guides/12-dates-time-zones-and-amounts.html) for the rules it follows. # V2 class and appointment period filters are renamed The classes and appointments lists name their start-time bounds after the `starts_at` field they filter: `period_start` becomes `starts_after` and `period_end` becomes `starts_before`. The defaults are unchanged: from now to 30 days from now, each bound on its own. A plain date is read as midnight in the company's time zone. A request that still sends the old names is refused with `BSPORT-400`. This V2 change shipped before general availability, so it applies in place to V2 REST requests. V1 is unchanged. See [Dates, time zones and amounts](https://api-docs.production.bsport.io/guides/12-dates-time-zones-and-amounts.html) for the rules it follows. # V2 class passes rename `base_price` to `price` Class passes, their webhooks and the class pass a client class pass expands with `expand[]=class_pass_id` return their price as `price`, like appointment passes and products. `price` is now a decimal string, `"56.00"` instead of `56.0`, and `base_price`, which carried the same amount, is removed. Creating a class pass takes `price`; a request that still sends `base_price` is refused with a `400`. Sort with `ordering=price`: `ordering=base_price` is ignored. This V2 change shipped before general availability, so it applies in place to V2 REST requests, responses and webhook payloads. V1 is unchanged. See [Dates, time zones and amounts](https://api-docs.production.bsport.io/guides/12-dates-time-zones-and-amounts.html) for the rules it follows. # V2 coupon discount value is a decimal string Coupon `discount.value` is now a decimal string, like the value you send: `10.5` becomes `"10.50"`. This V2 change shipped before general availability, so it applies in place to V2 REST responses and V2 webhook payloads. V1 is unchanged. See [Dates, time zones and amounts](https://api-docs.production.bsport.io/guides/12-dates-time-zones-and-amounts.html) for the rules it follows. # V2 datetimes keep a numeric UTC offset A zero UTC offset is now written `+00:00`, never `Z`, in every V2 datetime. Companies at UTC+0 see the change: UTC companies, and the UK, Ireland and Portugal in winter. Parse datetimes with an ISO 8601 parser that accepts both forms. Class `bookable_from`, `bookable_until` and `cancelable_until` now use the company's time zone, like `starts_at`, instead of the venue's. The moment they describe is unchanged. This V2 change shipped before general availability, so it applies in place to V2 REST responses and V2 webhook payloads. V1 is unchanged. See [Dates, time zones and amounts](https://api-docs.production.bsport.io/guides/12-dates-time-zones-and-amounts.html) for the rules it follows. # V2 days derived from a moment use the company's day Client `joined_date` and client subscription `first_billing_date` and `last_billing_date` are now days in the company's time zone, not in UTC. A client who joined at 00:30 on March 11, 2026, in Paris now has `joined_date` `2026-03-11`, the day `joined_after_date` and `joined_before_date` match. A billing date in a time zone above UTC+12 no longer shows the day before. This V2 change shipped before general availability, so it applies in place to V2 REST responses and V2 webhook payloads. V1 is unchanged. See [Dates, time zones and amounts](https://api-docs.production.bsport.io/guides/12-dates-time-zones-and-amounts.html) for the rules it follows. # V2 gift-card range amounts are decimal strings Gift-card `minimum_amount` and `maximum_amount` are now decimal strings in responses: `10` becomes `"10.00"`. Requests accept a decimal string or a number, and still refuse an amount with cents. This V2 change shipped before general availability, so it applies in place to V2 REST requests, responses and webhook payloads. V1 is unchanged. See [Dates, time zones and amounts](https://api-docs.production.bsport.io/guides/12-dates-time-zones-and-amounts.html) for the rules it follows. # V2 invoice items return the manual discount reason V2 invoice items now return `discount_reason`, the reason staff entered for a manual discount on the item. It is `null` when the item has no manual discount or no reason was entered. Discount codes, packs, referrals and pro-rata never fill it: discount code names stay in `/api/v2/management/coupon-usages/`. It appears in `/api/v2/management/invoice-items/` responses. # V2 invoice line amounts are decimal strings The amounts in invoice `line_items.data` are now decimal strings in major currency units, like the other invoice amounts: `tax_included_unit_amount`, `tax_included_amount`, `voucher_applied`, `line_total`, and `tax_breakdown.total_tax` and `tax_breakdown.unit_tax`. `4900` becomes `"49.00"`. `tax_breakdown.rate` becomes a decimal-string percentage: `20.0` becomes `"20.000"`. This V2 change shipped before general availability, so it applies in place to V2 REST responses and V2 webhook payloads. V1 is unchanged. See [Dates, time zones and amounts](https://api-docs.production.bsport.io/guides/12-dates-time-zones-and-amounts.html) for the rules it follows. # V2 invoices link a reverse invoice to the invoice it refunds V2 invoices now return `source_invoice_id`. On a reverse invoice it is the `id` of the invoice it refunds. It is `null` on every other invoice and on the reverse invoices of partial pass refunds, which are not linked to an invoice. It appears in `/api/v2/management/invoices/` responses, in the invoice that invoice items expand with `expand[]=invoice_id`, and in the `invoice.created` and `invoice.updated` webhook payloads. It carries the same value as `source_invoice_id` in the [Back Office invoice webhooks](https://api-docs.production.bsport.io/webhooks/invoice-webhook.html). # V2 refuses unknown query parameters A V2 request that sends a query parameter its operation does not support now fails with `400` and code `BSPORT-400`, instead of ignoring the parameter: a list no longer returns unfiltered results for a misspelled filter. Filters, `ordering`, `page`, `page_size`, `expand[]` and the other parameters an operation documents, such as `fields` on clients, keep working. The response lists each problem in `invalid_params`, with the closest supported name in `suggestion` when there is one, and links to [Query parameter errors](https://api-docs.production.bsport.io/guides/04-errors-and-statuses.html#query-parameter-errors) in `doc_url`. An invalid filter value now uses the same body, with `reason` `invalid_value`: `{"ids": ["Enter a number."], "status": 400}` becomes an `invalid_params` entry for `ids`. A boolean filter such as `is_archived` now refuses a value other than `true`, `false`, `1` or `0` instead of ignoring it, and an empty ID list such as `ids=` is refused instead of returning every result; any other empty value still means no filter. This applies to every V2 operation, creates and actions included. An unsupported `ordering` field is still ignored. Compare the parameters your integration sends with each operation's parameters in the API Reference. # Venue management endpoints Create, list and retrieve operations for company venues: - `POST /api/v1/management/venues/` - Create a new venue - `GET /api/v1/management/venues/` - List venues - `GET /api/v1/management/venues/{id}/` - Retrieve venue details V1 has no operation to update a venue. `PATCH /api/v2/management/venues/{id}/` is available in V2. **New capabilities** (May 13-19): - Validate latitude and longitude boundaries - Timezone configuration per venue # Versioned webhook registrations New webhook registrations always use the V2 REST endpoint and the V2 event catalogue. V1 registration creation is retired: POST on `/api/v1/management/webhook-registrations/` returns `410` with code `WHR-002`. MCP creates webhook registrations through V2. Existing registrations retain their immutable V1 payload contract, including registrations previously created through a V2 route. Reads and updates remain available. New V2 deliveries use canonical event names such as `class.updated`, V2 resource shapes, and payload header date `2026-10-06`; existing V1 deliveries retain their historical names and date `2026-08-22`. Retries and replay preserve the registration's version. See [webhook setup](https://api-docs.production.bsport.io/webhooks/01-public-api-webhooks.html) and [existing V1 registrations](https://api-docs.production.bsport.io/webhooks/06-v1-registrations.html). # `X-Timezone-Name` applies to V2 requests With a company or franchise API key, a V2 `GET` request now uses the time zone `X-Timezone-Name` names for response datetimes, for the days derived from them, and for the filter datetimes and days you send without an offset. Write requests, requests without the header and requests with an unknown time zone name keep the company's time zone, as before. V1 and webhooks keep the company's time zone. # Optional # Migrate from V1 to V2 V1 retires on January 15, 2027 The legacy V1 routes outside `/api/v1/management/` are removed on November 30, 2026. Migrate before these dates. Use this guide to move a REST integration from V1 to V2. It lists every route, field, filter and ID that changes, and the order in which to check them. It does not cover webhook payloads or MCP: see [Webhooks and MCP](#webhooks-and-mcp). ## Before you switch Moving to V2 requires changes to URLs, field names and stored ID mappings. Start with services and teachers: some IDs keep the same field name but refer to different records, so requests succeed and return the wrong data. What does not change: the base URL, authentication headers, tenant headers, the pagination envelope, rate limits and the error shape. See [Getting started](https://api-docs.production.bsport.io/guides/00-getting-started.html) and [Pagination and filtering](https://api-docs.production.bsport.io/guides/03-pagination-and-filtering.html). Confirm that V2 responds in your environment before you switch: ```bash curl -X GET \ -H 'X-Api-Key: YOUR_API_KEY' \ -H 'X-Client-ID: YOUR_CLIENT_ID' \ -H 'X-Company-ID: YOUR_COMPANY_ID' \ 'https://YOUR_ENV_DOMAIN/api/v2/monitoring/health/ping/' ``` Replace `YOUR_ENV_DOMAIN` with `public.production.bsport.io`. The comparison in this guide uses the [V1 schema](https://api-docs.production.bsport.io/schemas/openapi.yml) and the [V2 schema](https://api-docs.production.bsport.io/schemas/openapi-v2.yml). ## Routes Use `/api/v2/management/` for V2. Three paths also change. Read the table from left to right to find the V2 route and what to update. | V1 route | V2 route | Migration action | | ------------------------------- | ---------------------------------- | ------------------------------------------------------------------- | | `/management/passes/` | `/management/class-passes/` | Update list and detail URLs and generated resource names. | | `/management/client-passes/` | `/management/client-class-passes/` | Update list and detail URLs and the enable and disable action URLs. | | `/monitoring/health/anon_ping/` | `/monitoring/health/anon-ping/` | Update anonymous health-check URLs if you use them. | V2 has no `/passes/` or `/client-passes/` aliases. The legacy routes under `/api/v1/` have no direct V2 copies. They are removed on November 30, 2026. Read the table to find the Management endpoint that replaces each one. | Legacy V1 route | Replacement in V2 | | -------------------------- | ----------------------------------- | | `/bookings/` | `/management/bookings/` | | `/members/` | `/management/clients/` | | `/contracts/` | `/management/subscriptions/` | | `/billing_plans/` | `/management/client-subscriptions/` | | `/payment_packs/` | `/management/client-class-passes/` | | `/consumer_payment_packs/` | `/management/client-class-passes/` | Field names also change between the legacy and Management responses. Check the V2 reference for each resource and use the tables below for the renamed fields. ## Service and teacher IDs ### Class services On classes, `service_id` changes from an internal scheduling record ID to a public service ID, returned by `/api/v2/management/services/`. The `service_id` filter uses the new ID too. Reload services and classes for each company to rebuild your mappings. Reusing a V1 number can select an unrelated V2 service. Legacy classes without a linked service return `service_id: null`. ### Teachers Read the table by surface. Each row shows what the ID meant in V1, what it means in V2, and what to change. | Surface | V1 | V2 | Required adjustment | | ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- | | Class `teacher_id` and filter | Effective teacher: the substitute when assigned, otherwise the main teacher. Already a company-specific teacher ID. | Main teacher. `substitute_teacher_id` is separate. | Use `current_teacher_id` to filter the teacher actually running a class. For display, prefer the substitute when present. | | Appointment `teacher_id` | Platform-wide coach ID. | Company-specific teacher ID returned by `/teachers/`. | Rebuild cached teacher references. Do not reuse the V1 number. | | Booking `teacher_id`, `substitute_teacher_id` and `teacher_ids` filter | Coach IDs. | Company-specific teacher IDs returned by `/teachers/`. | Update joins and filters to the V2 Teachers ID space. | Teacher IDs are company-specific: the same person can have different IDs in two companies. Allow null main-teacher IDs on legacy classes and bookings. IDs returned by the Teachers endpoint itself are unchanged. ## Classes, appointments and bookings ### Classes and appointments Read the table by resource. Each row is one rename. | Resource | V1 | V2 | | --------------------------------------- | --------------------------- | ------------------------ | | Classes and appointments | `is_cancelled` | `is_canceled` | | Classes and appointments | `cancellable_until` | `cancelable_until` | | Appointments | `cancelled_at` | `canceled_at` | | Appointments, response and list filter | `service_id` | `appointment_service_id` | | Appointments, request body and response | `slot_id` | `appointment_slot_id` | | Classes | `is_bookable_by_members` | `is_bookable_by_clients` | | Classes | `current_waiting_list_size` | `current_waitlist_size` | | Classes | `max_waiting_list_size` | `max_waitlist_size` | On appointments, `appointment_service_id` keeps the old `service_id` value and `appointment_slot_id` keeps the old `slot_id` value. Classes keep the name `service_id`, with the different ID meaning described above. V2 also adds `level_id` and `substitute_teacher_id` to classes. ### Bookings Read the table by surface. Each row is one change. | Surface | V1 | V2 | | ---------------------------------------- | -------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | | Create payload, response and list filter | `client_pass_id` | `client_class_pass_id` | | Create payload | `session_ids` alias | Use `class_ids`. It is required and non-empty. | | Response | `session_id`, `session_start_at` aliases | Use `class_id`, `class_start_at`. | | Response | `location_id` | `venue_id` | | List filters | `session_id`, `session_ids` | `class_id`, `class_ids` | | List filters | `session_started_after_date`, `session_started_before_date`, taking a date | `class_start_after`, `class_start_before`, taking a timestamp. A plain date is read as midnight in the company's time zone. | | List filters | `has_session_ended`, `is_workshop_session` | `has_class_ended`, `is_workshop_class` | | List filter | `location_ids` | `venue_ids` | | List filter | `meta_activity_ids` | `service_ids` | | Ordering | `class_start_date`, `session_start_date` | `class_start_at` | The `activity_ids` filter is removed. To use `service_ids`, first resolve the public services that correspond to your old activity IDs. Rename `expand[]` paths as well, for example `client_pass_id` -> `client_class_pass_id`, and parse expanded objects with their V2 field names. ## Clients, notes, tags and teachers ### Client creation Read the table from left to right to convert a V1 creation body. | V1 input | V2 input | | -------------------------- | ------------------------------------------ | | `membership` | `client_reference` | | `membership.membership_id` | `client_reference.client_reference_number` | | `phone.phone_number` | Top-level `phone_number` string | | `address.zipcode` | `address.zip_code` | Creation requires `client_reference.joined_date`. Marketing-consent fields also belong inside `client_reference`. A V2 creation request looks like this (synthetic data): ```json { "firstname": "Alex", "lastname": "Example", "client_reference": { "joined_date": "2026-10-06", "client_reference_number": "external-123", "is_email_accepted": false }, "phone_number": "+33612345678", "address": {"zip_code": "75001"} } ``` ### Client responses and nested notes Read the table from left to right. Each row is one field. | V1 | V2 | | -------------------------------------------- | ---------------------------------------------------------- | | `membership_id` | `client_reference_number` | | `default_billing_establishment_id` | `default_billing_venue_id` | | `default_establishment_billing_location_id` | Removed. No like-for-like field is published. | | `client_account` | Removed. `client_account_balance` is the client's balance. | | `general_terms_and_conditions_accepted_date` | `general_terms_and_conditions_accepted_at` | | `general_terms_of_use_accepted_date` | `general_terms_of_use_accepted_at` | | `notes[].member` | `notes[].client_id` | | `notes[].date` | `notes[].creation_date` | | `notes[].editable` | `notes[].is_editable` | | `notes[].highlighted` | `notes[].is_highlighted` | | Client ordering `credit_account_balance` | `client_account_balance` | Both date fields, `birth_date` and `joined_date`, use `YYYY-MM-DD`. The V2 schema declares `joined_date` non-nullable: check legacy records when you update generated client types. V2 adds `PATCH /clients/{id}/`. Omitted fields stay unchanged. An address object updates only its supplied fields, and `address: null` leaves the address intact. Email can be set at creation but is rejected in `PATCH`. V1 has no `PUT` operation, so there is nothing to migrate. ### Other field changes and validation Read the table by resource. | Resource | V1 | V2 | | --------------------------------- | ------------------------------------ | ---------------------------------------------------------- | | Client-note response and ordering | `created_on` | `creation_date` | | Tags and tag groups | `date_created` | `created_at` | | Teachers | `first_name`, `last_name`, `phone` | `firstname`, `lastname`, `phone_number` | | Tag creation | Optional, nullable free-form `color` | Required lowercase `#rrggbb` string. Null is not accepted. | Tag and untag actions and tag-group references require positive IDs from the authenticated company. ## Class passes and client class passes ### Class-pass response mapping Read the table from left to right. Each row maps a V1 `/passes/` field to its V2 `/class-passes/` field. | V1 field | V2 field | | ------------------------------ | ----------------------------------------- | | `meta_activity_ids` | `service_ids` | | `establishment_ids` | `venue_ids` | | `applies_for_payroll` | `is_used_for_payroll` | | `grants_door_access` | `is_door_access_granted` | | `no_show_penalty_active` | `is_no_show_penalty_active` | | `pass_category_id` | `class_pass_category_id` | | `should_allow_guest_pass` | `is_guest_allowed` | | `tags_on_client_pass_creation` | `on_purchase_tag_ids` | | `theoretical_margin_value` | `estimated_revenue_amount` | | `linked_private_pass_id` | `linked_appointment_pass_id` | | `validity_daterange` | `validity_period` | | `bookkeeping_account_id` | Removed. No replacement in this response. | Inside `validity_period`, rename `lower` to `start_date`, `upper` to `end_date`, and `empty` to `is_empty`. Keep reading `bounds` to determine whether the end date is included. The object can be null. Rename the list filter `category_id` to `class_pass_category_id`. The rename `meta_activity_ids` -> `service_ids` preserves the existing IDs: both refer to the same record. ### Client class passes Read the table from left to right. | V1 | V2 | | ------------------------------------------------------------ | ------------------------------------------------ | | `pass_id` | `class_pass_id` | | `pass_template_instance_id` | `class_pass_template_instance_id` | | `master_client_pass_id` | `master_client_class_pass_id` | | `linked_private_client_pass_id` | `linked_client_appointment_pass_id` | | List filters `pass_id`, `pass_ids` | `class_pass_id`, `class_pass_ids` | | List filter `client_id` | Use `client_ids`, including for a single client. | | Enable and disable query parameter `spread_to_shared_passes` | `should_spread_to_shared_passes` | V2 declares `purchased_date` and `is_disabled` read-only. Use the enable and disable actions to change state: `PATCH` is not supported. Rename expansions too: `expand[]=pass_id` becomes `expand[]=class_pass_id`. ## Subscriptions V2 keeps `/subscriptions/` and `/client-subscriptions/` for reads. New subscription writes and pause operations are not part of V2. Read the table by surface. | Surface | V1 | V2 | | --------------------------------------------------------------- | ------------------------- | ----------------------------- | | Subscription response | `contract_template_id` | `subscription_template_id` | | Subscription response | `contract_terms` | `subscription_terms` | | Subscription response | `contract_terms_pdf_link` | `subscription_terms_pdf_link` | | Subscription response | `tags_on_first_billing` | `on_first_billing_tag_ids` | | Both subscription resources, response and `benefit_type` filter | `pass` | `class_pass` | Replace `pass` with `class_pass` in response parsing and in `benefit_type` filters. `appointment_pass` and `pack` are unchanged. ## New in V2 The V2 objects with no V1 equivalent need no migration. Read [Other objects added in V2](https://api-docs.production.bsport.io/guides/08-terminology.html#other-objects-added-in-v2) for what each one is, and [V2 workflows and field conventions](https://api-docs.production.bsport.io/guides/10-v2-workflows.html) for how to use them. When you adopt invoices, check the amount units: every amount, nested line items included, is a decimal string in major currency units. For communications, a retry can send duplicates and `processed` does not mean delivered. ## Webhooks and MCP This guide covers the REST API. MCP and webhooks follow different rules. **MCP.** MCP tools use the V2 contract, with V2 field names and IDs. You do not migrate anything on the MCP side, but the tool list is the V2 one. See the [MCP overview](https://api-docs.production.bsport.io/guides/mcp.html). **Webhooks.** The payload version belongs to the registration: - An existing registration keeps delivering V1 payloads and historical event names such as `offer-update`. Its `data` keeps V1 field names and IDs, for example booking `session_id` and class `service_id`. It does not change on its own. This includes registrations that were created through a V2 route before payload versioning was introduced. - A new registration is always created through `/api/v2/management/webhook-registrations/`. Creating one through V1 returns `410` with code `WHR-002`. It delivers V2 payloads with canonical event names such as `class.updated`, and its `data` matches the V2 response of the same resource, for example booking `class_id`. To move an existing integration to V2 payloads, create a new registration for the V2 event, then disable the old one once your receiver handles the new shape. Use a separate receiver URL for each version while both exist, because a registration cannot be switched from V1 to V2. See [Webhook event payloads](https://api-docs.production.bsport.io/webhooks/05-event-payloads.html) and [existing V1 registrations](https://api-docs.production.bsport.io/webhooks/06-v1-registrations.html). ## Migration checklist Work through the steps in order. 1. List the routes, fields, filters, ordering values and expansions your integration uses, including scheduled exports. 1. Update them using the tables above. Regenerate your API client from the V2 schema if you use one, and check required fields, nullable IDs and each operation's error responses. 1. Reload service and teacher mappings per company. Test classes with substitutes and legacy records with null references. 1. Compare reads on test data. Check filter results: an obsolete parameter can leave a query broader than intended. 1. Test writes outside production, including invalid IDs, tag colors, omitted fields and explicit nulls. V1 and V2 share data, so sending the same write to both can create duplicates. 1. Plan webhooks separately: existing registrations keep V1 payloads, and new ones use V2. Create the V2 registration next to the V1 one, compare the deliveries, then disable the V1 registration. 1. Switch one flow at a time. Keep the V1 mappings available for rollback. Returning to V1 does not undo writes already made through V2.