> 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.

# Reemplazar el horario semanal de una persona

PUT https://app.recurrente.com/api/staff_members/{staff_member_id}/schedule
Content-Type: application/json

Reemplaza su semana con `blocks`: uno por tramo, dos para un día con
pausa. Un día sin tramos queda cerrado. Con `uses_business_hours: true`
deja su horario propio y vuelve al del negocio. Si un tramo no se lee
como horario, no cambia nada y responde `422` con `code: invalid_schedule`.


Reference: https://docs.recurrente.com/referencia-api/api-reference/bookings/replace-staff-member-schedule

## 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

### Path parameters

- `staff_member_id` (string, required)

### Body (application/json)

This endpoint expects an object.

- `uses_business_hours` (boolean, optional)
- `blocks` (list of WeeklyScheduleBlock, optional)

## Response

### 200

El horario nuevo

- `owner_id` (string, optional) — La cuenta (`ac_`) o la persona del equipo (`stf_`).
- `uses_business_hours` (boolean, optional) — Una persona sin horario propio trabaja el del negocio; `blocks` son entonces los del negocio.
- `time_zone` (string, optional)
- `blocks` (list of WeeklyScheduleBlock, optional)

## Errors

### 422 Unprocessable Entity Error

Un tramo no es un horario válido (`invalid_schedule`)

- `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

### WeeklyScheduleBlock

- `weekday` (integer, required) — 0 es domingo, 6 es sábado.
- `opens_at` (string, required)
- `closes_at` (string, required)

### ErrorErrors

Detalles de errores por campo

## Examples

**Request**

```json
{
  "blocks": [
    {
      "weekday": 1,
      "opens_at": "08:30",
      "closes_at": "12:30"
    },
    {
      "weekday": 1,
      "opens_at": "13:30",
      "closes_at": "17:30"
    },
    {
      "weekday": 3,
      "opens_at": "10:00",
      "closes_at": "16:00"
    }
  ]
}
```

**Response**

```json
{
  "owner_id": "stf_9876543210",
  "uses_business_hours": false,
  "time_zone": "America/Guatemala",
  "blocks": [
    {
      "weekday": 1,
      "opens_at": "08:30",
      "closes_at": "12:30"
    },
    {
      "weekday": 1,
      "opens_at": "13:30",
      "closes_at": "17:30"
    },
    {
      "weekday": 3,
      "opens_at": "10:00",
      "closes_at": "16:00"
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://app.recurrente.com/api/staff_members/staff_member_id/schedule"

payload = { "blocks": [
        {
            "weekday": 1,
            "opens_at": "08:30",
            "closes_at": "12:30"
        },
        {
            "weekday": 1,
            "opens_at": "13:30",
            "closes_at": "17:30"
        },
        {
            "weekday": 3,
            "opens_at": "10:00",
            "closes_at": "16:00"
        }
    ] }
headers = {
    "X-SECRET-KEY": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://app.recurrente.com/api/staff_members/staff_member_id/schedule';
const options = {
  method: 'PUT',
  headers: {'X-SECRET-KEY': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"blocks":[{"weekday":1,"opens_at":"08:30","closes_at":"12:30"},{"weekday":1,"opens_at":"13:30","closes_at":"17:30"},{"weekday":3,"opens_at":"10:00","closes_at":"16:00"}]}'
};

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/staff_members/staff_member_id/schedule"

	payload := strings.NewReader("{\n  \"blocks\": [\n    {\n      \"weekday\": 1,\n      \"opens_at\": \"08:30\",\n      \"closes_at\": \"12:30\"\n    },\n    {\n      \"weekday\": 1,\n      \"opens_at\": \"13:30\",\n      \"closes_at\": \"17:30\"\n    },\n    {\n      \"weekday\": 3,\n      \"opens_at\": \"10:00\",\n      \"closes_at\": \"16:00\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("PUT", 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/staff_members/staff_member_id/schedule")

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

request = Net::HTTP::Put.new(url)
request["X-SECRET-KEY"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"blocks\": [\n    {\n      \"weekday\": 1,\n      \"opens_at\": \"08:30\",\n      \"closes_at\": \"12:30\"\n    },\n    {\n      \"weekday\": 1,\n      \"opens_at\": \"13:30\",\n      \"closes_at\": \"17:30\"\n    },\n    {\n      \"weekday\": 3,\n      \"opens_at\": \"10:00\",\n      \"closes_at\": \"16:00\"\n    }\n  ]\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.put("https://app.recurrente.com/api/staff_members/staff_member_id/schedule")
  .header("X-SECRET-KEY", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"blocks\": [\n    {\n      \"weekday\": 1,\n      \"opens_at\": \"08:30\",\n      \"closes_at\": \"12:30\"\n    },\n    {\n      \"weekday\": 1,\n      \"opens_at\": \"13:30\",\n      \"closes_at\": \"17:30\"\n    },\n    {\n      \"weekday\": 3,\n      \"opens_at\": \"10:00\",\n      \"closes_at\": \"16:00\"\n    }\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://app.recurrente.com/api/staff_members/staff_member_id/schedule', [
  'body' => '{
  "blocks": [
    {
      "weekday": 1,
      "opens_at": "08:30",
      "closes_at": "12:30"
    },
    {
      "weekday": 1,
      "opens_at": "13:30",
      "closes_at": "17:30"
    },
    {
      "weekday": 3,
      "opens_at": "10:00",
      "closes_at": "16:00"
    }
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-SECRET-KEY' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://app.recurrente.com/api/staff_members/staff_member_id/schedule");
var request = new RestRequest(Method.PUT);
request.AddHeader("X-SECRET-KEY", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"blocks\": [\n    {\n      \"weekday\": 1,\n      \"opens_at\": \"08:30\",\n      \"closes_at\": \"12:30\"\n    },\n    {\n      \"weekday\": 1,\n      \"opens_at\": \"13:30\",\n      \"closes_at\": \"17:30\"\n    },\n    {\n      \"weekday\": 3,\n      \"opens_at\": \"10:00\",\n      \"closes_at\": \"16:00\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-SECRET-KEY": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["blocks": [
    [
      "weekday": 1,
      "opens_at": "08:30",
      "closes_at": "12:30"
    ],
    [
      "weekday": 1,
      "opens_at": "13:30",
      "closes_at": "17:30"
    ],
    [
      "weekday": 3,
      "opens_at": "10:00",
      "closes_at": "16:00"
    ]
  ]] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://app.recurrente.com/api/staff_members/staff_member_id/schedule")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
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()
```