Documentation / Recursos Avançados
Recursos Avançados

How to Create an Account (Organization) Via API

Create an Account

The eAgenda platform API allows you to create accounts (organizations) programmatically, configuring information such as name, contact, time zone, and status. This practical guide explains how to send an HTTP POST request to the /api/v3/accounts/ endpoint and process the response. For more details, see the official eAgenda API documentation: https://eagenda.com.br/api/v3/documents/#overview.

Environment Setup

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 authentication section in the API documentation to configure the token correctly: https://eagenda.com.br/api/v3/documents/#overview.

Account Data Definition

To create an account, send a JSON object in the request body with the following fields:

{
  "slug": "string",
  "name": "string",
  "website": "string",
  "email": "email",
  "phone": "string",
  "url_domain": "uri",
  "time_zone": "string",
  "is_active": boolean
}

slug (required)

  • Description: Unique identifier for the organization (slug).
  • Restrictions: Minimum of 1 character, pattern ^[-a-zA-Z0-9_]+$.
  • Impact: Used to identify the account in the system.
  • Example: “minha-organizacao”

name (optional)

  • Description: Company or business name.
  • Restrictions: Maximum of 50 characters.
  • Impact: Sets the visible name of the organization.
  • Example: “Minha Saúde Ltda”

website (optional)

  • Description: URL of the organization’s website.
  • Restrictions: Maximum of 250 characters.
  • Impact: Adds a link to the company’s website.
  • Example: “https://www.minhasaude.com.br

email (optional)

  • Description: Organization’s contact email.
  • Impact: Used for account-related communications.
  • Example: “contato@minhasaude.com.br

phone (optional)

  • Description: Organization’s contact phone number.
  • Restrictions: Maximum of 15 characters.
  • Impact: Adds a contact number.
  • Example: “+5511999999999”

url_domain (optional)

time_zone (optional)

  • Description: Organization’s time zone.
  • Restrictions: Must be a valid time zone (e.g., America/Sao_Paulo).
  • Impact: Sets the time zone for appointments and notifications.
  • Example: “America/Sao_Paulo”

is_active (optional)

  • Description: Organization’s status.
  • Impact: Determines whether the account is active (true) or inactive (false).
  • Example: true

Note: The slug field is required. All other fields are optional but recommended for greater control and customization.

Basic Example:

{
  "slug": "minha-organizacao",
  "name": "Minha Saúde Ltda",
  "email": "contato@minhasaude.com.br",
  "time_zone": "America/Sao_Paulo",
  "is_active": true
}

Sending the Request to Create an Account

To create an account, send an HTTP POST request to the endpoint:

https://eagenda.com.br/api/v3/accounts/

Request Configuration

  • Method: POST
  • Headers:
    • accept: application/json
    • Authorization: Bearer
    • Content-Type: application/json
  • Request body: JSON with the account data.

cURL Request Example

curl -X POST https://eagenda.com.br/api/v3/accounts/ \
-H "accept: application/json" \
-H "Authorization: Bearer ba08ab41bd58e9b9f82b4d2788b3cd9999ee9999" \
-H "Content-Type: application/json" \
-d '{
  "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
}'

Python Example (using requests)

import requests

url = "https://eagenda.com.br/api/v3/accounts/"
headers = {
    "accept": "application/json",
    "Authorization": "Bearer ba08ab41bd58e9b9f82b4d2788b3cd9999ee9999",
    "Content-Type": "application/json"
}
data = {
    "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
}

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

Verifying the Response

The API will return a response with the account creation status. Check the following:

  • HTTP status code:
    • 201 Created: Account created successfully.
    • 400 Bad Request: Error in the submitted data (check the JSON).
    • 401 Unauthorized: Invalid or missing token.
  • Response body: Contains the details of the created account, such as:
{
  "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
}

The account will be registered in the system and ready to be used in other operations, such as creating calendars or appointments.

Conclusion

With this tutorial, you learned how to create an account (organization) via the eAgenda API, configuring details such as slug, name, contact, and time zone efficiently. This integration is ideal for automating the creation of organizations, streamlining account management in the system. For more features, such as creating calendars or appointments, see the full eAgenda API documentation.

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