How to Create Schedulable Services Via API in eAgenda

Overview
The eAgenda platform API allows you to create services programmatically, enabling the automation of service registration with details such as name, duration, price, and maximum number of clients. This practical guide details how to configure an HTTP POST request to the /api/v3/services/ endpoint and process the response. For more details, see the official eAgenda API documentation.
Environment Setup for Creating Services
Before you begin, you will need:
- API Key: Access the eAgenda dashboard to obtain your Bearer token.
- HTTP request tool: Use cURL, Postman, or libraries such as requests (Python) or axios (JavaScript).
- Header configuration: Authentication is done via Bearer Token. Set the header Authorization: Bearer
and define Content-Type: application/json.
Tip: See the eAgenda authentication documentation to configure the token correctly.
Data Definition for Creating Services
To create a service, send a JSON object in the request body with the following fields:
{
"service_name": "string",
"duration": "string",
"price": "decimal",
"max_clients": integer,
"account_slug": "string"
}
service_name (required)
- Description: Service name.
- Constraints: Minimum of 1 character.
- Impact: Identifies the service in the system, displayed to clients and staff.
- Example: “Medical Consultation”
duration (required)
- Description: Service duration (free format, usually in minutes or HH:MM).
- Impact: Defines the time reserved for the service, affecting scheduling.
- Example: “00:30”
price (required)
- Description: Service price.
- Constraints: Must be a decimal number (e.g., 100.50) or null. Maximum of 3 integer digits and 2 decimal digits (pattern: ^-?\d{0,3}(?:\.\d{0,2})?$).
- Impact: Determines the cost of the service for the client.
- Example: 150.00
max_clients (required)
- Description: Maximum number of clients per time slot.
- Constraints: Must be an integer or null.
- Impact: Controls the service capacity per time slot.
- Example: 5
account_slug (optional)
- Description: Slug of the account or sub-account associated with the service.
- Constraints: Minimum of 1 character, pattern ^[-a-zA-Z0-9_]+$.
- How to obtain the account_slug: Use the eAgenda account listing endpoint (see documentation).
- Impact: Links the service to a specific account, useful for organizations with multiple accounts.
- Example: “minha-conta”
Note: The fields service_name, duration, price, and max_clients are required. The account_slug field is optional but recommended to link the service to a specific account.
Sending the Request to Create a Service
To create the service, send an HTTP POST request to the endpoint:
https://eagenda.com.br/api/v3/services/
Request Configuration
- Method: POST
- Headers:
- accept: application/json
- Authorization: Bearer
- Content-Type: application/json
- Request body: JSON with the service data.
cURL Request Example
curl -X POST https://eagenda.com.br/api/v3/services/ \
-H "accept: application/json" \
-H "Authorization: Bearer ba08ab41bd58e9b9f82b4d2788b3cd9999ee9999" \
-H "Content-Type: application/json" \
-d '{
"service_name": "Consulta Médica",
"duration": "00:30",
"price": 150.00,
"max_clients": 5,
"account_slug": "minha-conta"
}'
Python Example (using requests)
import requests
url = "https://eagenda.com.br/api/v3/services/"
headers = {
"accept": "application/json",
"Authorization": "Bearer ba08ab41bd58e9b9f82b4d2788b3cd9999ee9999",
"Content-Type": "application/json"
}
data = {
"service_name": "Consulta Médica",
"duration": "00:30",
"price": 150.00,
"max_clients": 5,
"account_slug": "minha-conta"
}
response = requests.post(url, json=data, headers=headers)
print(response.status_code)
print(response.json())
Response Verification
The API will return a response with the service creation status. Check the following:
- HTTP status code:
- 201 Created: Service created successfully.
- 400 Bad Request: Error in the submitted data (check the JSON).
- 401 Unauthorized: Invalid or missing token.
- Response body: Contains details of the created service, such as:
{ "service_key": "19730681-2aa0-4000-84b6-2bc54b4ace01", "service_name": "Consulta Médica", "duration": "00:30", "price": "150.00", "max_clients": 5, "account_slug": "minha-conta" }
The service will be registered in the system and available for scheduling, following the defined settings. You can use other endpoints of the API to manage or query services.
Conclusion
With this tutorial, you learned how to create services via the eAgenda API, automating the registration of services with details such as duration, price, and capacity. This integration is ideal for managing service offerings efficiently. For more features, such as editing services or integrating with appointments, see the complete eAgenda API documentation.
Get in Touch or Learn More
We are here to help! Access our official channels:
📞 WhatsApp : Click here to send us a message 🌐 eAgenda Platform : Discover eAgenda 🏢 Our Company : Mupi Systems – Innovative Solutions 📧 Email : contato@mupisystems.com.br 📚 Tutorials and Documentation : Access our guides and tutorials