How to Authenticate with the API (Generate an Access Token)

Overview
The eAgenda platform API requires authentication to access its endpoints, primarily using the HTTP Bearer method with an access token. This practical guide explains how to generate the access token through the eAgenda dashboard and use it in HTTP requests. For more information, see the official eAgenda API documentation.
Environment Setup
Before you begin, you will need:
- Access credentials: An account with a valid login and password on the eAgenda dashboard (e.g., an email such as test@eagenda.com).
- Dashboard access: A web browser to access the eAgenda dashboard at https://eagenda.com.br.
- HTTP request tool: Use cURL, Postman, or libraries such as requests (Python) or axios (JavaScript) to test authentication.
Note: This tutorial focuses on Bearer Token authentication, which is the most common method for APIs. Other methods, such as HTTP Basic or cookie (__Secure-sessionid), are not covered here but can be explored in the documentation.
Step-by-Step Guide to Generate the Access Token
To obtain or generate an access token, see the full tutorial here, or follow the steps below in the eAgenda dashboard:
- Access the eAgenda dashboard:
- Open your browser and go to https://eagenda.com.br.
- Create an account or log in with your credentials (e.g., email eagenda@example.com and password).
- Navigate to the integrations section:
- In the left sidebar menu, click on Integrations.
- Access the API settings:
- On the Integrations page, click on the API option.
- Obtain or generate the token:
- If a token already exists, copy the displayed key (e.g., ba08ab41bd58e9b9f82b4d2788b3cd9999ee9999).
- If no token exists, click Generate to create a new key.
- Copy the generated token and store it in a secure location, as it will be needed to authenticate requests.
Tip: The token is sensitive and should be treated like a password. Do not share it publicly or expose it in code repositories.
Using the Token in HTTP Requests
After obtaining the token, use it in HTTP requests with Bearer authentication. The token must be included in the Authorization header in the format Bearer
Bearer Authentication Configuration
- HTTP Header:
- Authorization: Bearer
- Example: Authorization: Bearer ba08ab41bd58e9b9f82b4d2788b3cd9999ee9999
- Authorization: Bearer
- Other headers:
- accept: application/json (to receive responses in JSON).
- Content-Type: application/json (for requests that send data, such as POST or PATCH).
cURL Request Example
To test the authentication, let’s use the account listing endpoint (/api/v3/accounts/) as an example:
curl -X GET https://eagenda.com.br/api/v3/accounts/ \
-H "accept: application/json" \
-H "Authorization: Bearer ba08ab41bd58e9b9f82b4d2788b3cd9999ee9999"
Python Example (using requests)
import requests
url = "https://eagenda.com.br/api/v3/accounts/"
headers = {
"accept": "application/json",
"Authorization": "Bearer ba08ab41bd58e9b9f82b4d2788b3cd9999ee9999"
}
response = requests.get(url, headers=headers)
print(response.status_code)
print(response.json())
Note: Replace ba08ab41bd58e9b9f82b4d2788b3cd9999ee9999 with the token generated in the dashboard.
Verifying Authentication
The API will return a response indicating whether the authentication was successful. Check the following:
- HTTP status code:
- 200 OK: Authentication successful, and the request returned the requested data.
- 401 Unauthorized: Invalid, missing, or expired token. Generate a new token or verify the provided value.
- 403 Forbidden: The token is valid, but the account does not have permission to access the resource.
- Response body: For the account listing example, the response will look similar to:
[ { "slug": "minha-organizacao", "name": "Minha Saúde Ltda", "website": "https://www.minhasaude.com.br", "email": "contato@minhasaude.com.br", "phone": "+5511999999999", "url_domain": "https://agendamento.minhasaude.com.br", "time_zone": "America/Sao_Paulo", "is_active": true, "is_sub_account": false } ]
If you receive a 401 error, check the token in the Authorization header or generate a new token in the dashboard.
Conclusion
With this tutorial, you learned how to authenticate with the eAgenda API, generate the access token through the dashboard, and use it in HTTP requests with Bearer authentication. This integration is essential for securely accessing the API endpoints and performing operations such as creating accounts, appointments, or listing schedules. For more features, see the full eAgenda API documentation: https://eagenda.com.br/api/v3/documentation/#overview.
Contact Us or Learn More
We are here to help! Visit 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