> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.recurrente.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.recurrente.com/_mcp/server.

# Programar sesiones de una clase

POST https://app.recurrente.com/api/class_sessions
Content-Type: application/json

Escribe las sesiones de una clase con una regla semanal, como el
formulario de Clases: "martes y jueves a las 5:45, del 6 de octubre al
15 de diciembre". `weekdays` va de 0 (domingo) a 6 y `time` es HH:MM en
la zona del negocio. Es todo o nada: si el instructor o el salón ya
están ocupados a alguna de esas horas, no escribe ninguna (`busy`). Una
hora fuera del horario del negocio, del instructor o del salón se salta
y aparece en `skipped_starts_at`. Cada sesión tiene el cupo de la clase.
Para apartar un lugar usa `POST /bookings` con `class_session_id`.


Reference: https://docs.recurrente.com/referencia-api/api-reference/bookings/create-class-sessions

## Authentication

- `X-SECRET-KEY` header (required) — Tu clave secreta de API. Una llave de cuenta (`sk_live_...`, `sk_test_...`) opera sobre su propia cuenta y, con `X-ACCOUNT-ID`, sobre sus cuentas conectadas. La llave también fija el ambiente: una `sk_test_` solo lista y resuelve objetos de prueba (`live_mode: false`) y una `sk_live_` solo objetos reales. Un ID del otro ambiente responde `404` (`401` en `/customers`). Una llave de organización (`sk_org_live_...`, `sk_org_test_...`) alcanza todas las cuentas de una organización y solo sirve para leer: saldos, movimientos y reportes. Para operar sobre una cuenta debe nombrarla con `X-ACCOUNT-ID`; omitirlo en una lectura devuelve todas las cuentas de la organización. Cualquier otro endpoint responde `403` con `code: organization_key_unsupported`.

## Request

### Body (application/json)

This endpoint expects an object.

- `service_id` (string, required) — La clase (un servicio `kind: class`).
- `staff_member_id` (string, required) — Quién la da.
- `weekdays` (list of integer, required)
- `time` (string, required)
- `from_on` (date, required)
- `until_on` (date, required)
- `resource_id` (string, optional) — El salón o recurso que ocupa, si ocupa uno.

## Response

### 201

Las sesiones escritas y las horas que se saltaron

- `sessions` (list of ClassSession, optional)
- `skipped_starts_at` (list of datetime, optional) — Las horas que caen fuera del horario y no se escribieron.

## Errors

### 400 Bad Request Error

El servicio no es una clase (`not_a_class`) o una fecha es inválida

- `message` (string, optional) — Mensaje de error
- `code` (string, optional) — Código estable legible por máquinas, cuando aplica
- `refund_id` (string, optional) — ID del reembolso relacionado cuando aplica
- `endpoint` (string, optional) — Acción de API rechazada, cuando aplica
- `errors` (ErrorErrors, optional) — Detalles de errores por campo

### 422 Unprocessable Entity Error

La regla no es válida (`invalid_schedule`), escribe demasiadas sesiones (`too_many`), todas caen fuera del horario (`outside_hours`) o el instructor o el salón están ocupados (`busy`)

- `message` (string, optional) — Mensaje de error
- `code` (string, optional) — Código estable legible por máquinas, cuando aplica
- `refund_id` (string, optional) — ID del reembolso relacionado cuando aplica
- `endpoint` (string, optional) — Acción de API rechazada, cuando aplica
- `errors` (ErrorErrors, optional) — Detalles de errores por campo

## Types

### ClassSession

- `id` (string, optional)
- `account_id` (string, optional)
- `service_id` (string, optional) — La clase.
- `name` (string, optional)
- `staff_member_id` (string, optional, nullable)
- `resource_id` (string, optional, nullable)
- `starts_at` (datetime, optional)
- `ends_at` (datetime, optional)
- `capacity` (integer, optional)
- `seats_taken` (integer, optional)
- `seats_left` (integer, optional)
- `seat_booking_ids` (list of string, optional) — Las citas que ocupan un lugar.
- `cancelled_at` (datetime, optional, nullable)
- `created_at` (datetime, optional)

### ErrorErrors

Detalles de errores por campo

## Examples

**Request**

```json
{
  "service_id": "svc_yoga1234",
  "staff_member_id": "stf_maria5678",
  "weekdays": [
    2,
    4
  ],
  "time": "17:45",
  "from_on": "2026-10-06",
  "until_on": "2026-12-15"
}
```

**Response**

```json
{
  "sessions": [
    {
      "id": "cls_9876abcd",
      "account_id": "ac_123456",
      "service_id": "svc_yoga1234",
      "name": "Yoga",
      "staff_member_id": "stf_maria5678",
      "resource_id": "res_room101",
      "starts_at": "2026-10-06T17:45:00-06:00",
      "ends_at": "2026-10-06T18:45:00-06:00",
      "capacity": 12,
      "seats_taken": 7,
      "seats_left": 5,
      "seat_booking_ids": [
        "bk_00112233"
      ],
      "cancelled_at": "null",
      "created_at": "2026-09-01T10:00:00-06:00"
    },
    {
      "id": "cls_9876abce",
      "account_id": "ac_123456",
      "service_id": "svc_yoga1234",
      "name": "Yoga",
      "staff_member_id": "stf_maria5678",
      "resource_id": "res_room101",
      "starts_at": "2026-10-08T17:45:00-06:00",
      "ends_at": "2026-10-08T18:45:00-06:00",
      "capacity": 12,
      "seats_taken": 3,
      "seats_left": 9,
      "seat_booking_ids": [
        "bk_00445566"
      ],
      "cancelled_at": "null",
      "created_at": "2026-09-01T10:00:00-06:00"
    }
  ],
  "skipped_starts_at": [
    "2026-11-24T17:45:00-06:00"
  ]
}
```

**SDK Code**

```python
import requests

url = "https://app.recurrente.com/api/class_sessions"

payload = {
    "service_id": "svc_yoga1234",
    "staff_member_id": "stf_maria5678",
    "weekdays": [2, 4],
    "time": "17:45",
    "from_on": "2026-10-06",
    "until_on": "2026-12-15"
}
headers = {
    "X-SECRET-KEY": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://app.recurrente.com/api/class_sessions';
const options = {
  method: 'POST',
  headers: {'X-SECRET-KEY': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"service_id":"svc_yoga1234","staff_member_id":"stf_maria5678","weekdays":[2,4],"time":"17:45","from_on":"2026-10-06","until_on":"2026-12-15"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://app.recurrente.com/api/class_sessions"

	payload := strings.NewReader("{\n  \"service_id\": \"svc_yoga1234\",\n  \"staff_member_id\": \"stf_maria5678\",\n  \"weekdays\": [\n    2,\n    4\n  ],\n  \"time\": \"17:45\",\n  \"from_on\": \"2026-10-06\",\n  \"until_on\": \"2026-12-15\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-SECRET-KEY", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://app.recurrente.com/api/class_sessions")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-SECRET-KEY"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"service_id\": \"svc_yoga1234\",\n  \"staff_member_id\": \"stf_maria5678\",\n  \"weekdays\": [\n    2,\n    4\n  ],\n  \"time\": \"17:45\",\n  \"from_on\": \"2026-10-06\",\n  \"until_on\": \"2026-12-15\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://app.recurrente.com/api/class_sessions")
  .header("X-SECRET-KEY", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"service_id\": \"svc_yoga1234\",\n  \"staff_member_id\": \"stf_maria5678\",\n  \"weekdays\": [\n    2,\n    4\n  ],\n  \"time\": \"17:45\",\n  \"from_on\": \"2026-10-06\",\n  \"until_on\": \"2026-12-15\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://app.recurrente.com/api/class_sessions', [
  'body' => '{
  "service_id": "svc_yoga1234",
  "staff_member_id": "stf_maria5678",
  "weekdays": [
    2,
    4
  ],
  "time": "17:45",
  "from_on": "2026-10-06",
  "until_on": "2026-12-15"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-SECRET-KEY' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://app.recurrente.com/api/class_sessions");
var request = new RestRequest(Method.POST);
request.AddHeader("X-SECRET-KEY", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"service_id\": \"svc_yoga1234\",\n  \"staff_member_id\": \"stf_maria5678\",\n  \"weekdays\": [\n    2,\n    4\n  ],\n  \"time\": \"17:45\",\n  \"from_on\": \"2026-10-06\",\n  \"until_on\": \"2026-12-15\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-SECRET-KEY": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "service_id": "svc_yoga1234",
  "staff_member_id": "stf_maria5678",
  "weekdays": [2, 4],
  "time": "17:45",
  "from_on": "2026-10-06",
  "until_on": "2026-12-15"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://app.recurrente.com/api/class_sessions")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```