Escalas
Recuperar dados de todas as escalas da empresa
GET
https://escala.med.br/api/v2/partner/schedules
Através deste endpoint é possível recuperar todas as escalas de uma empresa.
Chamada
curl --location 'https://escala.med.br/api/v2/partner/schedules' \
--header 'Authorization: <API_TOKEN>'
Resultado da chamada
Este endpoint retorna um objeto com todos os dados das escalas criadas pela empresa.
{
[
{
"id": 1,
"name": "Escala de exemplo",
"checkin": false,
"conflicts_between_departments_enabled": true,
"conflicts_in_department_enabled": true,
"allow_edit_grid": true,
"allow_edit_schedule_info": true,
"tags": [
"PLANTAO"
],
"periods": [
{
"unit_id": 4,
"period_id": 4,
"name": "Manhã",
"unit_name": "Manhã",
"start": "06:00:00",
"end": "12:00:00",
"slots": 1,
"week_days_exception": [
"saturday",
"sunday"
],
"tags": [],
"date_start": "2023-11-28"
},
{
"unit_id": 5,
"period_id": 5,
"name": "Tarde",
"unit_name": "Tarde",
"start": "12:00:00",
"end": "18:00:00",
"slots": 1,
"week_days_exception": [
"saturday",
"sunday"
],
"tags": [],
"date_start": "2023-11-28"
}
]
}
]
}
Recuperar dados de uma escala especifica
GET
https://escala.med.br/api/v2/partner/schedule
É possível buscar uma escala pelo nome, ou id.
Chamada
curl --location 'https://escala.med.br/api/v2/partner/schedule?schedule_id=<ID_ESCALA>&include_professionals=0' \
--header 'Authorization: Bearer <API_TOKEN>'
Parâmetros
{
"name":"Escala Teste 4",
"address":{
"street":"Rua Madre Cabrini, 462 - Vila Mariana, Sao Paulo - SP, Brasil",
"number":null,
"district":null,
"city":"Sao Paulo",
"state":"",
"country":"BR"
},
"checkin":1,
"checkin_config":{
"checkin_radius_in_km":"0.50000000",
"checkin_window_in_min":15,
"checkout_delay_in_min":15,
"checkout_limit_in_min":15,
"allow_checkin_outside_checkin_area":1
},
"conflicts_between_departments_enabled":1,
"conflicts_in_department_enabled":1,
"allow_edit_grid":1,
"allow_edit_schedule_info":1,
"tags":[
"COMP:ALTA",
"ESC:MARINA",
"EXIG:FEM",
"GER:BRADESCO",
"VALOR:R$50.000"
],
"periods":[
{
"name":"Periodo7",
"unit_id": 1235,
"period_id": 2223,
"external_id":"P7",
"start":"07:00:00",
"end":"19:00:00","slots":1,
"week_days_exception":[
"monday",
"thursday",
"friday",
"sunday"
],
"tags":[
"VALOR:R$5.000"
],
"date_start":"2019-07-01",
"date_end":"2019-08-11"
},
{
"name":"Periodo8",
"external_id":"P8",
"unit_id": 1234,
"period_id": 2222,
"start":"07:00:00",
"end":"19:00:00",
"slots":1,
"week_days_exception":[],
"tags":[
"VALOR:R$3.000"
],
"date_start":"2019-07-01",
"date_end":"2019-08-11"
}
]
}
{
"name":"Escala Teste 4",
"address":{
"street":"Rua Madre Cabrini, 462 - Vila Mariana, Sao Paulo - SP, Brasil",
"number":null,
"district":null,
"city":"Sao Paulo",
"state":"",
"country":"BR"
},
"checkin":1,
"checkin_config":{
"checkin_radius_in_km":"0.50000000",
"checkin_window_in_min":15,
"checkout_delay_in_min":15,
"checkout_limit_in_min":15,
"allow_checkin_outside_checkin_area":1
},
"conflicts_between_departments_enabled":1,
"conflicts_in_department_enabled":1,
"allow_edit_grid":1,
"allow_edit_schedule_info":1,
"tags":[
"COMP:ALTA",
"ESC:MARINA",
"EXIG:FEM",
"GER:BRADESCO",
"VALOR:R$50.000"
],
"periods":[
{
"name":"Periodo7",
"external_id":"P7",
"unit_id": 1235,
"period_id": 2226,
"start":"07:00:00",
"end":"19:00:00","slots":1,
"week_days_exception":[
"monday",
"thursday",
"friday",
"sunday"
],
"tags":[
"VALOR:R$5.000"
],
"date_start":"2019-07-01",
"date_end":"2019-08-11"
},
{
"name":"Periodo8",
"external_id":"P8",
"unit_id": 1236,
"period_id": 2227,
"start":"07:00:00",
"end":"19:00:00",
"slots":1,
"week_days_exception":[],
"tags":[
"VALOR:R$3.000"
],
"date_start":"2019-07-01",
"date_end":"2019-08-11"
}
],
"professionals": [
{
"id": 16,
"name": "Ciclana Rocha",
"roles": [
"professional"
],
"cellphone": "11912341235",
"email": "ciclana@mymail.co",
"gender": "female",
"tags": []
}
]
}
Contagem de vagas (slots) para um período
GET
https://escala.med.br/api/v2/partner/slotcount
Devolve a contagem de vagas em cada dia para um período consultado.
Chamada
curl --location 'https://escala.med.br/api/v2/partner/slotcount?schedule_id=<SCHEDULE_ID>&from=2024-08-01&to=2024-08-31' \
--header 'Authorization: Bearer <API_TOKEN>'
Parâmetros
Resposta
[
{
"unit_id": 1,
"name": "Equipe 1",
"count_on_date": [
"2021-12-01": 2,
"2021-12-02": 1,
"2021-12-03": 2
]
},
{
"unit_id": 2,
"name": "Equipe 2",
"count_on_date": [
"2021-12-01": 1,
"2021-12-02": 1,
"2021-12-03": 1
]
}
]
Criação e Edição de escalas
Existem dois métodos que permitem a criação e edição de escalas.
A principal diferença entre os dois é que um permite a inclusão de turnos de trabalho e profissionais (/partner/schedule
)
Enquanto o outro permite realizar modificações na grade com um maior controle (/partner/scheduleperiods
)
Criar ou Editar uma escala e plantões
POST
https://escala.med.br/api/v2/partner/schedule
Definições dos objetos a serem utilizados na sequência:
Request Body Schema
Chamada
curl --location 'https://escala.med.br/api/v2/partner/schedule' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer cm9kaW5laSBsaW1hIGVzY2FsYSBhcHAgcGxhbnRvZXMgdGVzdGUgZGUgQVBJCg==' \
--header 'Cookie: laravel_session=eyJpdiI6Ik8yK2dVbUEza0w1MGh1WTYzeG5OU1E9PSIsInZhbHVlIjoiemhweml2dkpETnk3Qmp5RWpZdzk0UHRqdUt0QkI5ZW1qb1VMNk92MDQrNzZKd0VlNTdPMkVEOXJaZzhHSGZJN1lMTzRsTHZjRTFobzhnUWJlb3dVZHJHaHlOSkFkTmlOVnU0MXdTSTJsTk9aelI0VERJbHNSN0tPTGwwT2VzRHAiLCJtYWMiOiIxMDJmMWNhZjQ5MWQ2MDdmYjIwMzJmYWNlOTYxYmYxNjk1MWU5ZDEyZmQ5YTRkYjE1NWI3NTI0MGExNzU5ODk5IiwidGFnIjoiIn0%3D' \
--data '{
"schedules": [
{
"name": "Escala Teste",
"address": {
"street": "Rua Madre Cabrini",
"number": "462",
"district": "Vila Mariana",
"city": "Sao Paulo",
"state": "SP",
"country": "Brasil"
},
"checkin": false,
"checkin_config": {
"checkin_radius_in_km": 0.5,
"checkin_window_in_min": 15,
"checkout_delay_in_min": 15,
"checkout_limit_in_min": 15,
"allow_checkin_outside_checkin_area": true
},
"conflicts_between_departments_enabled": true,
"conflicts_in_department_enabled": true,
"allow_edit_grid": true,
"allow_edit_schedule_info": true,
"tags": [],
"periods": [
{
"name": "Periodo 01",
"external_id": "P1",
"start": "07:00:00",
"end": "12:00:00",
"slots": 1,
"week_days_exception": [
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"sunday"
],
"tags": [],
"date_start": "2024-07-01",
"date_end": "2024-07-30"
}
],
"professionals": []
}
]
}'
Resposta
{
"schedules": [
{
"name": "Escala Teste",
"address": {
"street": "Rua Madre Cabrini",
"number": "462",
"district": "Vila Mariana",
"city": "Sao Paulo",
"state": "SP",
"country": "Brasil"
},
"checkin": false,
"checkin_config": {
"checkin_radius_in_km": 0.5,
"checkin_window_in_min": 15,
"checkout_delay_in_min": 15,
"checkout_limit_in_min": 15,
"allow_checkin_outside_checkin_area": true
},
"conflicts_between_departments_enabled": true,
"conflicts_in_department_enabled": true,
"allow_edit_grid": true,
"allow_edit_schedule_info": true,
"tags": [],
"periods": [
{
"name": "Periodo 01",
"external_id": "P1",
"start": "07:00:00",
"end": "12:00:00",
"slots": 1,
"week_days_exception": [
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"sunday"
],
"tags": [],
"date_start": "2024-07-01",
"date_end": "2024-07-30"
}
],
"professionals": [],
"id": 30367
}
]
}
Editar escala e alocar plantões - exemplo 2
POST
https://escala.med.br/api/v2/partner/schedule
Utilizando o mesmo endpoint anterior, só que para realizar uma alocação de plantões
Chamada
curl --location 'https://escala.med.br/api/v2/partner/schedule' \
--header 'Content-Type: application/json' \
--header 'Cookie: laravel_session=eyJpdiI6Ik8yK2dVbUEza0w1MGh1WTYzeG5OU1E9PSIsInZhbHVlIjoiemhweml2dkpETnk3Qmp5RWpZdzk0UHRqdUt0QkI5ZW1qb1VMNk92MDQrNzZKd0VlNTdPMkVEOXJaZzhHSGZJN1lMTzRsTHZjRTFobzhnUWJlb3dVZHJHaHlOSkFkTmlOVnU0MXdTSTJsTk9aelI0VERJbHNSN0tPTGwwT2VzRHAiLCJtYWMiOiIxMDJmMWNhZjQ5MWQ2MDdmYjIwMzJmYWNlOTYxYmYxNjk1MWU5ZDEyZmQ5YTRkYjE1NWI3NTI0MGExNzU5ODk5IiwidGFnIjoiIn0%3D' \
--data-raw '{
"schedules": [
{
"name": "Escala Teste",
"address": {
"street": "Rua Madre Cabrini",
"number": "462",
"district": "Vila Mariana",
"city": "Sao Paulo",
"state": "SP",
"country": "Brasil"
},
"checkin": false,
"checkin_config": {
"checkin_radius_in_km": 0.5,
"checkin_window_in_min": 15,
"checkout_delay_in_min": 15,
"checkout_limit_in_min": 15,
"allow_checkin_outside_checkin_area": true
},
"conflicts_between_departments_enabled": true,
"conflicts_in_department_enabled": true,
"allow_edit_grid": true,
"allow_edit_schedule_info": true,
"tags": [],
"periods": [
{
"name": "Periodo 01",
"external_id": "P1",
"start": "08:00:00",
"end": "10:00:00",
"slots": 1,
"week_days_exception": [],
"tags": [],
"date_start": "2024-07-01",
"date_end": "2024-07-30"
}
],
"professionals": [
{
"name": "Profissional Dois",
"nickname": "Profissional Dois",
"email": "professional@gmail.com",
"send_invite_when_submit": true,
"roles": [
"professional"
],
"internal_id": "444",
"cellphone": "11984224753",
"tags": [],
"gender": "male",
"shifts": [
{
"date": "2024-07-19",
"period_name": "Periodo 01",
"tags": []
},
{
"date": "2024-07-20",
"period_name": "Periodo 01",
"tags": []
},
{
"date": "2024-07-21",
"period_name": "Periodo 01",
"tags": []
}
]
}
]
}
]
}'
Resposta
{
"schedules": [
{
"name": "Escala Teste",
"address": {
"street": "Rua Madre Cabrini",
"number": "462",
"district": "Vila Mariana",
"city": "Sao Paulo",
"state": "SP",
"country": "Brasil"
},
"checkin": false,
"checkin_config": {
"checkin_radius_in_km": 0.5,
"checkin_window_in_min": 15,
"checkout_delay_in_min": 15,
"checkout_limit_in_min": 15,
"allow_checkin_outside_checkin_area": true
},
"conflicts_between_departments_enabled": true,
"conflicts_in_department_enabled": true,
"allow_edit_grid": true,
"allow_edit_schedule_info": true,
"tags": [],
"periods": [
{
"name": "Periodo 01",
"external_id": "P1",
"start": "08:00:00",
"end": "10:00:00",
"slots": 1,
"week_days_exception": [],
"tags": [],
"date_start": "2024-07-01",
"date_end": "2024-07-30"
}
],
"professionals": [
{
"name": "Profissional Dois",
"nickname": "Profissional Dois",
"email": "professional@gmail.com",
"send_invite_when_submit": true,
"roles": [
"professional"
],
"internal_id": "444",
"cellphone": "11984224753",
"tags": [],
"gender": "male",
"shifts": [
{
"date": "2024-07-19",
"period_name": "Periodo 01",
"tags": []
},
{
"date": "2024-07-20",
"period_name": "Periodo 01",
"tags": []
},
{
"date": "2024-07-21",
"period_name": "Periodo 01",
"tags": []
}
]
}
],
"id": 30368
}
]
}
Criar/Alterar uma escala com períodos
POST
https://escala.med.br/api/v2/partner/scheduleperiods
Requisição
curl --location 'https://escala.med.br/api/v2/partner/scheduleperiods' \
--header 'Content-Type: application/json' \
--data '{
"schedules": [
{
"periods_update_policy": "create_or_update",
"add_organizers_policy": true,
"name": "Escala Teste periodo",
"address": {
"street": "Rua Madre Cabrini",
"number": "462",
"district": "Vila Mariana",
"city": "Sao Paulo",
"state": "SP",
"country": "Brasil"
},
"checkin": false,
"checkin_config": {
"checkin_radius_in_km": 0.5,
"checkin_window_in_min": 15,
"checkout_delay_in_min": 15,
"checkout_limit_in_min": 15,
"allow_checkin_outside_checkin_area": true
},
"conflicts_between_departments_enabled": true,
"conflicts_in_department_enabled": true,
"allow_edit_grid": true,
"allow_edit_schedule_info": true,
"tags": [],
"periods": [
{
"name": "Periodo 01",
"external_id": "P1",
"start": "08:00:00",
"end": "10:00:00",
"slots": 1,
"week_days_exception": [],
"tags": [],
"date_start": "2024-07-01",
"date_end": "2024-07-30"
},
{
"name": "Periodo 02",
"external_id": "P2",
"start": "10:00:00",
"end": "11:00:00",
"slots": 2,
"week_days_exception": [],
"tags": [],
"date_start": "2024-07-01",
"date_end": "2024-07-30"
},
{
"name": "Periodo 03",
"external_id": "P3",
"start": "11:00:00",
"end": "12:00:00",
"slots": 3,
"week_days_exception": [],
"tags": [],
"date_start": "2024-07-01",
"date_end": "2024-07-30"
}
]
}
]
}'
Payload
{
"schedules": [
{
"periods_update_policy": "create_or_update",
"add_organizers_policy": true,
"name": "Escala Teste periodo",
"address": {
"street": "Rua Madre Cabrini",
"number": "462",
"district": "Vila Mariana",
"city": "Sao Paulo",
"state": "SP",
"country": "Brasil"
},
"checkin": false,
"checkin_config": {
"checkin_radius_in_km": 0.5,
"checkin_window_in_min": 15,
"checkout_delay_in_min": 15,
"checkout_limit_in_min": 15,
"allow_checkin_outside_checkin_area": true
},
"conflicts_between_departments_enabled": true,
"conflicts_in_department_enabled": true,
"allow_edit_grid": true,
"allow_edit_schedule_info": true,
"tags": [],
"periods": [
{
"name": "Periodo 01",
"external_id": "P1",
"start": "08:00:00",
"end": "10:00:00",
"slots": 1,
"week_days_exception": [],
"tags": [],
"date_start": "2024-07-01",
"date_end": "2024-07-30"
},
{
"name": "Periodo 02",
"external_id": "P2",
"start": "10:00:00",
"end": "11:00:00",
"slots": 2,
"week_days_exception": [],
"tags": [],
"date_start": "2024-07-01",
"date_end": "2024-07-30"
},
{
"name": "Periodo 03",
"external_id": "P3",
"start": "11:00:00",
"end": "12:00:00",
"slots": 3,
"week_days_exception": [],
"tags": [],
"date_start": "2024-07-01",
"date_end": "2024-07-30"
}
]
}
]
}
Parâmetros importantes
Parâmetros obrigatórios para criação de escalas que incluem períodos
"periods_update_policy": "create_or_update",
"add_organizers_policy": true,
Resposta
{
"schedules": [
{
"periods_update_policy": "create_or_update",
"add_organizers_policy": true,
"name": "Escala Teste periodo",
"address": {
"street": "Rua Madre Cabrini",
"number": "462",
"district": "Vila Mariana",
"city": "Sao Paulo",
"state": "SP",
"country": "Brasil"
},
"checkin": false,
"checkin_config": {
"checkin_radius_in_km": 0.5,
"checkin_window_in_min": 15,
"checkout_delay_in_min": 15,
"checkout_limit_in_min": 15,
"allow_checkin_outside_checkin_area": true
},
"conflicts_between_departments_enabled": true,
"conflicts_in_department_enabled": true,
"allow_edit_grid": true,
"allow_edit_schedule_info": true,
"tags": [],
"periods": [
{
"name": "Periodo 01",
"external_id": "P1",
"start": "08:00:00",
"end": "10:00:00",
"slots": 1,
"week_days_exception": [],
"tags": [],
"date_start": "2024-07-01",
"date_end": "2024-07-30",
"unit_id": 17154,
"period_id": 18390
},
{
"name": "Periodo 02",
"external_id": "P2",
"start": "10:00:00",
"end": "11:00:00",
"slots": 2,
"week_days_exception": [],
"tags": [],
"date_start": "2024-07-01",
"date_end": "2024-07-30",
"unit_id": 17155,
"period_id": 18391
},
{
"name": "Periodo 03",
"external_id": "P3",
"start": "11:00:00",
"end": "12:00:00",
"slots": 3,
"week_days_exception": [],
"tags": [],
"date_start": "2024-07-01",
"date_end": "2024-07-30",
"unit_id": 17156,
"period_id": 18392
}
],
"id": 30369
}
]
}
Alterações pontuais à grade de uma escala
POST
https://escala.med.br/api/v2/partner/schedulegrid
É possível adicionar e remover vagas (slots) à equipes através de ações (actions). No momento disponibilizamos 2 ações (add_slot
) e (remove_slot
).
É importante notar que remover vagas em um dia que tenha turnos irá apagar os mesmos.
Os parâmetros são passados como um array de objetos do tipo ação, com os campos:
Destes, apenas o to
é opcional. count
é a contagem de vagas a serem abertas ou encerradas. period_id
é o id do período já criado.
Pode ser resgatado através do GET
/schedule
Chamada
curl --location 'https://escala.med.br/api/v2/partner/schedulegrid?XDEBUG_SESSION_START=PHPSTORM' \
--header 'Content-Type: application/json' \
--data '{
"actions": [
{
"action": "add_slot",
"count": 1,
"from": "2024-07-18",
"to": "2024-07-19",
"period_id": 9
},
{
"action": "remove_slot",
"count": 2,
"from": "2024-07-22",
"to": "2024-07-23",
"period_id": 9
}
],
"callback_url": "https://www.example.com/my_private_callback_url"
}'
Resposta
{
"request_id": 37
}
Exemplo de payload correto
{
"actions": [
{
"action": "add_slot",
"count": 1,
"from": "2024-07-18",
"to": "2024-07-19",
"period_id": 9
},
{
"action": "remove_slot",
"count": 2,
"from": "2024-07-22",
"to": "2024-07-23",
"period_id": 9
}
],
"callback_url": "https://www.example.com/my_private_callback_url"
}
Last updated