> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tess.im/llms.txt
> Use this file to discover all available pages before exploring further.

# Prévia de Agendamento

> Valida uma definição de agendamento e retorna as próximas ocorrências previstas.

### **Exemplos de Código**

<CodeGroup>
  ```http cURL theme={null}
  curl --request POST \
    --url 'https://api.tess.im/digital-employees/schedule-preview' \
    --header 'Authorization: Bearer YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --header 'x-workspace-id: YOUR_WORKSPACE_ID' \
    --data '{
      "heartbeat_cron": "0 9 * * 1-5",
      "execution_timezone": "America/Sao_Paulo"
    }'
  ```

  ```json Node.js theme={null}
  const axios = require('axios');

  const data = {
    "heartbeat_cron": "0 9 * * 1-5",
    "execution_timezone": "America/Sao_Paulo"
  };

  const config = {
    method: 'post',
    url: 'https://api.tess.im/digital-employees/schedule-preview',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json',
      'x-workspace-id': 'YOUR_WORKSPACE_ID'
    },
    data: data
  };

  try {
    const response = await axios(config);
    console.log(response.data);
  } catch (error) {
    console.error(error);
  }
  ```

  ```python Python theme={null}
  import requests
  import json

  url = "https://api.tess.im/digital-employees/schedule-preview"
  headers = {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json",
      "x-workspace-id": "YOUR_WORKSPACE_ID"
  }
  data = {
      "heartbeat_cron": "0 9 * * 1-5",
      "execution_timezone": "America/Sao_Paulo"
  }

  response = requests.post(url, headers=headers, json=data)
  print(response.json())
  ```

  ```php PHP theme={null}
  <?php
  $curl = curl_init();

  $data = [
      "heartbeat_cron" => "0 9 * * 1-5",
      "execution_timezone" => "America/Sao_Paulo"
  ];

  curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.tess.im/digital-employees/schedule-preview",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => json_encode($data),
    CURLOPT_HTTPHEADER => [
      "Authorization: Bearer YOUR_API_KEY",
      "Content-Type: application/json",
      "x-workspace-id: YOUR_WORKSPACE_ID"
    ]
  ]);

  $response = curl_exec($curl);
  $err = curl_error($curl);

  curl_close($curl);

  if ($err) {
    echo "Error: " . $err;
  } else {
    echo $response;
  }
  ```

  ```java Java theme={null}
  import com.fasterxml.jackson.databind.ObjectMapper;
  import java.net.URI;
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;
  import java.util.Map;

  public class Main {
      public static void main(String[] args) throws Exception {
          ObjectMapper mapper = new ObjectMapper();

          Map<String, Object> data = Map.of(
              "heartbeat_cron", "0 9 * * 1-5",
              "execution_timezone", "America/Sao_Paulo"
          );

          String jsonPayload = mapper.writeValueAsString(data);

          HttpClient client = HttpClient.newHttpClient();
          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create("https://api.tess.im/digital-employees/schedule-preview"))
              .header("Authorization", "Bearer YOUR_API_KEY")
              .header("Content-Type", "application/json")
              .header("x-workspace-id", "YOUR_WORKSPACE_ID")
              .POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
              .build();

          HttpResponse<String> response = client.send(request,
              HttpResponse.BodyHandlers.ofString());
          System.out.println(response.body());
      }
  }
  ```

  ```go Go theme={null}
  package main

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

  func main() {
      payload := `{
          "heartbeat_cron": "0 9 * * 1-5",
          "execution_timezone": "America/Sao_Paulo"
      }`

      client := &http.Client{}
      req, err := http.NewRequest("POST", "https://api.tess.im/digital-employees/schedule-preview", strings.NewReader(payload))
      if err != nil {
          fmt.Println(err)
          return
      }

      req.Header.Add("Authorization", "Bearer YOUR_API_KEY")
      req.Header.Add("Content-Type", "application/json")
      req.Header.Add("x-workspace-id", "YOUR_WORKSPACE_ID")

      resp, err := client.Do(req)
      if err != nil {
          fmt.Println(err)
          return
      }
      defer resp.Body.Close()

      body, err := ioutil.ReadAll(resp.Body)
      if err != nil {
          fmt.Println(err)
          return
      }

      fmt.Println(string(body))
  }
  ```

  ```jsonnet .NET theme={null}
  using System;
  using System.Net.Http;
  using System.Text;
  using System.Threading.Tasks;
  using Newtonsoft.Json;

  class Program
  {
      static async Task Main(string[] args)
      {
          using (var client = new HttpClient())
          {
              client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_API_KEY");
              client.DefaultRequestHeaders.Add("x-workspace-id", "YOUR_WORKSPACE_ID");

              var data = new
              {
                  heartbeat_cron = "0 9 * * 1-5",
                  execution_timezone = "America/Sao_Paulo"
              };

              var jsonPayload = JsonConvert.SerializeObject(data);
              var content = new StringContent(jsonPayload, Encoding.UTF8, "application/json");

              try
              {
                  var response = await client.PostAsync(
                      "https://api.tess.im/digital-employees/schedule-preview",
                      content
                  );
                  response.EnsureSuccessStatusCode();
                  string responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine(responseBody);
              }
              catch (HttpRequestException e)
              {
                  Console.WriteLine("\nException Caught!");
                  Console.WriteLine("Message :{0} ", e.Message);
              }
          }
      }
  }
  ```

  ```ruby Ruby theme={null}
  require 'uri'
  require 'net/http'
  require 'json'

  uri = URI('https://api.tess.im/digital-employees/schedule-preview')
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(uri)
  request['Authorization'] = 'Bearer YOUR_API_KEY'
  request['Content-Type'] = 'application/json'
  request['x-workspace-id'] = 'YOUR_WORKSPACE_ID'
  request.body = {
      "heartbeat_cron": "0 9 * * 1-5",
      "execution_timezone": "America/Sao_Paulo"
  }.to_json

  response = http.request(request)
  puts response.read_body
  ```
</CodeGroup>

### **Cabeçalhos**

<Note>
  A autenticação é realizada via o cabeçalho `Authorization: Bearer YOUR_API_KEY`.
</Note>

<ParamField header="x-workspace-id" type="integer" required>
  ID do workspace. Obrigatório em todos os endpoints da API de Digital Employees.
</ParamField>

### **Parâmetros do Corpo**

<Note>
  Ao menos um entre `heartbeat_cron` ou `heartbeat_schedule_json` deve ser fornecido no corpo da requisição.
</Note>

<ParamField body="heartbeat_cron" type="string">
  Expressão cron que define o agendamento (ex.: `0 9 * * 1-5` para dias úteis às 9h). Ao menos um entre `heartbeat_cron` ou `heartbeat_schedule_json` deve ser fornecido.
</ParamField>

<ParamField body="heartbeat_schedule_json" type="object">
  Objeto de configuração do construtor de agendamento. Alternativa ao `heartbeat_cron`. Ao menos um entre `heartbeat_cron` ou `heartbeat_schedule_json` deve ser fornecido.
</ParamField>

<ParamField body="execution_timezone" type="string">
  Fuso horário para avaliação do agendamento (ex.: `America/Sao_Paulo`). Padrão: UTC se não informado.
</ParamField>

### **Resposta**

```json theme={null}
{
  "data": {
    "effective_cron": "0 9 * * 1-5",
    "next_occurrences": [
      "2026-06-30T09:00:00-03:00",
      "2026-07-01T09:00:00-03:00",
      "2026-07-02T09:00:00-03:00"
    ]
  }
}
```
