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

# Agregar un día libre o una ausencia

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

`closed` le cierra el día; `hours` lo deja trabajar solo en ese horario;
`personal` le quita ese tiempo (una cita con el médico), o el día entero
sin horario. Solo cierra su día, no el del negocio.


Reference: https://docs.recurrente.com/referencia-api/api-reference/bookings/create-staff-member-availability-exception

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

- `on` (date, required)
- `kind` (enum, required)
  - Allowed values: `closed`, `hours`, `personal`
- `opens_at` (string, optional) — Requerido con `hours`. Ignorado con `closed`.
- `closes_at` (string, optional)
- `note` (string, optional)

## Response

### 201

Fecha agregada

- `id` (string, optional)
- `on` (date, optional)
- `kind` (enum, optional) — `closed` cierra el día; `hours` lo abre solo en el horario indicado; `personal` (y los importados `external` y `maintenance`) quitan ese tiempo, o el día entero sin horario.
  - Allowed values: `closed`, `hours`, `personal`, `external`, `maintenance`
- `opens_at` (string, optional, nullable)
- `closes_at` (string, optional, nullable)
- `note` (string, optional, nullable)
- `imported` (boolean, optional) — Vino de un calendario (iCal o Google). Lo maneja la sincronización y no se puede quitar aquí.
- `created_at` (datetime, optional)

## Errors

### 422 Unprocessable Entity Error

Datos inválidos (por ejemplo, `hours` sin horario)

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

### ErrorErrors

Detalles de errores por campo

## Examples

**Request**

```json
{
  "on": "2026-12-24",
  "kind": "closed"
}
```

**Response**

```json
{
  "id": "avx_ab12cd34",
  "on": "2026-12-24",
  "kind": "closed",
  "opens_at": "09:00",
  "closes_at": "12:00",
  "note": "Nochebuena",
  "imported": true,
  "created_at": "2024-01-15T09:30:00Z"
}
```

**SDK Code**

```python
import requests

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

payload = {
    "on": "2026-12-24",
    "kind": "closed"
}
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/staff_members/staff_member_id/availability_exceptions';
const options = {
  method: 'POST',
  headers: {'X-SECRET-KEY': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"on":"2026-12-24","kind":"closed"}'
};

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/availability_exceptions"

	payload := strings.NewReader("{\n  \"on\": \"2026-12-24\",\n  \"kind\": \"closed\"\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/staff_members/staff_member_id/availability_exceptions")

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  \"on\": \"2026-12-24\",\n  \"kind\": \"closed\"\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/staff_members/staff_member_id/availability_exceptions")
  .header("X-SECRET-KEY", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"on\": \"2026-12-24\",\n  \"kind\": \"closed\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://app.recurrente.com/api/staff_members/staff_member_id/availability_exceptions', [
  'body' => '{
  "on": "2026-12-24",
  "kind": "closed"
}',
  '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/availability_exceptions");
var request = new RestRequest(Method.POST);
request.AddHeader("X-SECRET-KEY", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"on\": \"2026-12-24\",\n  \"kind\": \"closed\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-SECRET-KEY": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "on": "2026-12-24",
  "kind": "closed"
] 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/availability_exceptions")! 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()
```