### User-Agent Examples Source: https://docs.asaas.com/docs/autentica%C3%A7%C3%A3o Provides examples of how to format the User-Agent string for different applications and environments. Customizing this header improves visibility and support. ```http User-Agent: MinhaLoja/1.0.3 (Node.js; produção) ``` ```http User-Agent: ERPInterno/2.1 (Java_17; staging) ``` -------------------------------- ### POST /v3/anticipations Source: https://docs.asaas.com/docs/antecipacoes Request an anticipation for a single payment or an installment plan. For installment plans, anticipation can be for the entire plan or individual installments if the payment method is a credit card. If the payment method is a bank slip, anticipation must be for each installment individually. ```APIDOC ## POST /v3/anticipations ### Description Requests an anticipation for a payment or installment. ### Method POST ### Endpoint /v3/anticipations ### Parameters #### Request Body - **payment** (string) - Required - The ID of the payment to anticipate. - **installment** (string) - Required - The ID of the installment plan to anticipate. ### Request Example ```json { "payment": "pay_626366773834" } ``` ### Response #### Success Response (200) - **id** (string) - The ID of the anticipation request. - **status** (string) - The status of the anticipation. - **isDocumentationRequired** (boolean) - Indicates if documentation is required for the anticipation. #### Response Example ```json { "id": "antic_1234567890", "status": "PENDING", "isDocumentationRequired": true } ``` ### Notes - If the charge to be anticipated has a payment split defined, observe the rules for [Split in anticipated charges](https://docs.asaas.com/docs/split-em-cobrancas-antecipadas). - To determine if electronic invoices or service contracts are mandatory, check the `isDocumentationRequired` property returned in the [anticipation simulation](https://docs.asaas.com/reference/simular-antecipa%C3%A7%C3%A3o). ``` -------------------------------- ### Update Notification Settings Source: https://docs.asaas.com/docs/alterando-notificacoes-de-um-cliente Allows modification of notification settings for a specific event. The example shows how to configure an event to send only an email to the customer. ```APIDOC ## PUT /v3/notifications/{id} ### Description Updates the notification settings for a specific notification event. ### Method PUT ### Endpoint /v3/notifications/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the notification to update. ### Request Body - **enabled** (boolean) - Optional - Whether the notification is enabled overall. - **emailEnabledForProvider** (boolean) - Optional - Whether email notifications are enabled for the provider. - **smsEnabledForProvider** (boolean) - Optional - Whether SMS notifications are enabled for the provider. - **emailEnabledForCustomer** (boolean) - Optional - Whether email notifications are enabled for the customer. - **smsEnabledForCustomer** (boolean) - Optional - Whether SMS notifications are enabled for the customer. - **phoneCallEnabledForCustomer** (boolean) - Optional - Whether phone call notifications are enabled for the customer. - **whatsappEnabledForCustomer** (boolean) - Optional - Whether WhatsApp notifications are enabled for the customer. ### Request Example ```json { "enabled": true, "emailEnabledForProvider": false, "smsEnabledForProvider": false, "emailEnabledForCustomer": true, "smsEnabledForCustomer": false, "phoneCallEnabledForCustomer": false, "whatsappEnabledForCustomer": false } ``` ### Response #### Success Response (200) - **enabled** (boolean) - Indicates if the notification is enabled. - **emailEnabledForProvider** (boolean) - Indicates if email notifications are enabled for the provider. - **smsEnabledForProvider** (boolean) - Indicates if SMS notifications are enabled for the provider. - **emailEnabledForCustomer** (boolean) - Indicates if email notifications are enabled for the customer. - **smsEnabledForCustomer** (boolean) - Indicates if SMS notifications are enabled for the customer. - **phoneCallEnabledForCustomer** (boolean) - Indicates if phone call notifications are enabled for the customer. - **whatsappEnabledForCustomer** (boolean) - Indicates if WhatsApp notifications are enabled for the customer. #### Response Example ```json { "enabled": true, "emailEnabledForProvider": false, "smsEnabledForProvider": false, "emailEnabledForCustomer": true, "smsEnabledForCustomer": false, "phoneCallEnabledForCustomer": false, "whatsappEnabledForCustomer": false } ``` ``` -------------------------------- ### Retrieve Customer Notifications Source: https://docs.asaas.com/docs/alterando-notificacoes-de-um-cliente Fetches a list of all notification configurations associated with a specific customer. This is the first step to understanding the current notification setup for a client. ```APIDOC ## GET /v3/customers/{id}/notifications ### Description Retrieves a list of all notification configurations for a given customer. ### Method GET ### Endpoint /v3/customers/{id}/notifications ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the customer. ### Response #### Success Response (200) - **object** (string) - Type of the returned object, usually "list". - **hasMore** (boolean) - Indicates if there are more results than returned. - **totalCount** (integer) - The total number of notifications. - **limit** (integer) - The limit of notifications returned per request. - **offset** (integer) - The offset for pagination. - **data** (array) - An array of notification objects. - **object** (string) - Type of the notification object, "notification". - **id** (string) - The unique identifier of the notification. - **customer** (string) - The ID of the customer this notification belongs to. - **enabled** (boolean) - Whether the notification is generally enabled. - **emailEnabledForProvider** (boolean) - Whether email notifications are enabled via the provider. - **smsEnabledForProvider** (boolean) - Whether SMS notifications are enabled via the provider. - **emailEnabledForCustomer** (boolean) - Whether email notifications are enabled for the customer. - **smsEnabledForCustomer** (boolean) - Whether SMS notifications are enabled for the customer. - **phoneCallEnabledForCustomer** (boolean) - Whether phone call notifications are enabled for the customer. - **whatsappEnabledForCustomer** (boolean) - Whether WhatsApp notifications are enabled for the customer. - **event** (string) - The event that triggers this notification (e.g., PAYMENT_RECEIVED, PAYMENT_OVERDUE). - **scheduleOffset** (integer) - The number of days before or after an event that the notification should be sent. - **deleted** (boolean) - Indicates if the notification has been marked as deleted. #### Response Example ```json { "object": "list", "hasMore": false, "totalCount": 8, "limit": 10, "offset": 0, "data": [ { "object": "notification", "id": "not_000042762597", "customer": "cus_000005358829", "enabled": true, "emailEnabledForProvider": true, "smsEnabledForProvider": false, "emailEnabledForCustomer": true, "smsEnabledForCustomer": true, "phoneCallEnabledForCustomer": false, "whatsappEnabledForCustomer": false, "event": "PAYMENT_RECEIVED", "scheduleOffset": 0, "deleted": false } ] } ``` ``` -------------------------------- ### Consultar Nomes Disponíveis para Subconta PJ Source: https://docs.asaas.com/docs/alterar-o-nome-de-uma-subconta-pj-via-api Use esta requisição GET para obter a lista de nomes de empresa válidos e disponíveis para um CNPJ específico. A resposta inclui o campo `availableCompanyNames` com as opções. ```json { "object": "commercialInfo", "email": "empresa@exemplo.com.br", "companyName": "NOME ANTIGO DA EMPRESA LTDA", "availableCompanyNames": [ "NOME ATUALIZADO DA EMPRESA LTDA", "NOME FANTASIA ATUALIZADO" ], // ... outros campos } ``` -------------------------------- ### Update Notifications in Batch Source: https://docs.asaas.com/docs/alterando-notificacoes-de-um-cliente Alter multiple notification settings simultaneously using the batch update endpoint. This example demonstrates updating a specific customer's notifications. ```json { "customer": "cus_Y4AEif5zrMGK", "notifications": [ { "id": "not_f8JpoWuEjEKd", "enabled": true, "emailEnabledForProvider": true, "smsEnabledForProvider": true, "emailEnabledForCustomer": true, "smsEnabledForCustomer": true, "phoneCallEnabledForCustomer": false, "whatsappEnabledForCustomer": false }, { "id": "not_f8JpoWuEjEKd", "enabled": true, "emailEnabledForProvider": true, "smsEnabledForProvider": true, "emailEnabledForCustomer": true, "smsEnabledForCustomer": true, "phoneCallEnabledForCustomer": false, "whatsappEnabledForCustomer": false } ] } ``` -------------------------------- ### API Endpoint: Retrieve Business Data Source: https://docs.asaas.com/docs/annual-business-data-confirmation-for-subaccounts Use this GET endpoint to retrieve the current business data for a subaccount. This is recommended for confirming the validity of existing data or presenting it to the subaccount holder. ```http GET /v3/myAccount/commercialInfo/ ``` -------------------------------- ### Update Existing Notification Source: https://docs.asaas.com/docs/alterando-notificacoes-de-um-cliente Modify the notification settings for a specific event. This example shows how to enable only email notifications for the customer for payment creation. ```json { "enabled": true, "emailEnabledForProvider": false, "smsEnabledForProvider": false, "emailEnabledForCustomer": true, "smsEnabledForCustomer": false, "phoneCallEnabledForCustomer": false, "whatsappEnabledForCustomer": false } ``` -------------------------------- ### Incorrect API Key Format Error Source: https://docs.asaas.com/docs/authentication-2 This JSON response indicates that the provided API key does not conform to the expected Asaas format. Verify that the key starts with '$aact_prod_' for production or '$aact_hmlg_' for sandbox and contains no extra characters. ```json { "errors": [ { "code": "invalid_access_token_format", "description": "O valor fornecido não parece ser uma chave de API válida do Asaas. Verifique o formato da sua chave" } ] } ``` -------------------------------- ### Account Status Event Notification Example Source: https://docs.asaas.com/docs/account-status-events This JSON payload represents a notification received via webhook for an account status change. It includes the event type and the updated status of various account information fields. ```json { "event": "ACCOUNT_STATUS_COMMERCIAL_INFO_APPROVED", "accountStatus": { "id": "175027c1-029c-41e5-8b9a-e289b9788c33", "commercialInfo": "APPROVED", "bankAccountInfo": "APPROVED", "documentation": "APPROVED", "general": "APPROVED" } } ``` -------------------------------- ### URLs e API Keys para ambientes Sandbox e Produção Source: https://docs.asaas.com/docs/aprova%C3%A7%C3%A3o-de-contas Utilize a API Key e a URL correspondentes ao ambiente correto para evitar erros de autenticação e comportamentos inesperados. A API Key de Sandbox deve ser usada com a URL de Sandbox, e a API Key de produção com a URL de produção. ```plaintext API Key de Sandbox deve ser usada com https://api-sandbox.asaas.com/ ``` ```plaintext API Key de produção deve ser usada com https://api.asaas.com/ ``` -------------------------------- ### Suggested User-Agent Syntax Source: https://docs.asaas.com/docs/autentica%C3%A7%C3%A3o Defines the recommended format for the User-Agent request header to identify client applications. This helps in tracking and differentiating integrations. ```http User-Agent: / () ``` -------------------------------- ### Recuperar notificações de um cliente Source: https://docs.asaas.com/docs/alterando-notificacoes-de-um-cliente Use este endpoint para listar todas as notificações configuradas para um cliente específico. O retorno inclui detalhes como ID, status de habilitação e tipo de evento. ```json { "object": "list", "hasMore": false, "totalCount": 8, "limit": 10, "offset": 0, "data": [ { "object": "notification", "id": "not_000042762597", "customer": "cus_000005358829", "enabled": true, "emailEnabledForProvider": true, "smsEnabledForProvider": false, "emailEnabledForCustomer": true, "smsEnabledForCustomer": true, "phoneCallEnabledForCustomer": false, "whatsappEnabledForCustomer": false, "event": "PAYMENT_RECEIVED", "scheduleOffset": 0, "deleted": false }, { "object": "notification", "id": "not_000042762598", "customer": "cus_000005358829", "enabled": true, "emailEnabledForProvider": true, "smsEnabledForProvider": false, "emailEnabledForCustomer": true, "smsEnabledForCustomer": true, "phoneCallEnabledForCustomer": false, "whatsappEnabledForCustomer": false, "event": "PAYMENT_OVERDUE", "scheduleOffset": 0, "deleted": false }, { "object": "notification", "id": "not_000042762602", "customer": "cus_000005358829", "enabled": true, "emailEnabledForProvider": false, "smsEnabledForProvider": false, "emailEnabledForCustomer": true, "smsEnabledForCustomer": true, "phoneCallEnabledForCustomer": false, "whatsappEnabledForCustomer": false, "event": "PAYMENT_DUEDATE_WARNING", "scheduleOffset": 10, "deleted": false }, { "object": "notification", "id": "not_000042762601", "customer": "cus_000005358829", "enabled": true, "emailEnabledForProvider": false, "smsEnabledForProvider": false, "emailEnabledForCustomer": true, "smsEnabledForCustomer": true, "phoneCallEnabledForCustomer": false, "whatsappEnabledForCustomer": false, "event": "PAYMENT_DUEDATE_WARNING", "scheduleOffset": 0, "deleted": false }, { "object": "notification", "id": "not_000042762599", "customer": "cus_000005358829", "enabled": true, "emailEnabledForProvider": false, "smsEnabledForProvider": false, "emailEnabledForCustomer": true, "smsEnabledForCustomer": true, "phoneCallEnabledForCustomer": false, "whatsappEnabledForCustomer": false, "event": "PAYMENT_CREATED", "scheduleOffset": 0, "deleted": false }, { "object": "notification", "id": "not_000042762600", "customer": "cus_000005358829", "enabled": true, "emailEnabledForProvider": false, "smsEnabledForProvider": false, "emailEnabledForCustomer": true, "smsEnabledForCustomer": true, "phoneCallEnabledForCustomer": false, "whatsappEnabledForCustomer": false, "event": "PAYMENT_UPDATED", "scheduleOffset": 0, "deleted": false }, { "object": "notification", "id": "not_000042762604", "customer": "cus_000005358829", "enabled": true, "emailEnabledForProvider": false, "smsEnabledForProvider": false, "emailEnabledForCustomer": true, "smsEnabledForCustomer": true, "phoneCallEnabledForCustomer": false, "whatsappEnabledForCustomer": false, "event": "SEND_LINHA_DIGITAVEL", "scheduleOffset": 0, "deleted": false }, { "object": "notification", "id": "not_000042762603", "customer": "cus_000005358829", "enabled": true, "emailEnabledForProvider": false, "smsEnabledForProvider": false, "emailEnabledForCustomer": true, "smsEnabledForCustomer": true, "phoneCallEnabledForCustomer": false, "whatsappEnabledForCustomer": false, "event": "PAYMENT_OVERDUE", "scheduleOffset": 7, "deleted": false } ] } ``` -------------------------------- ### API Environment URLs Source: https://docs.asaas.com/docs/autentica%C3%A7%C3%A3o-1 Use the correct URL for Production and Sandbox environments when making API calls. ```APIDOC ## API Environment URLs ### Description After creating your account and generating an API key, use the specific URL for each environment in your calls. ### URLs | Environment | URL | |---|---| | Production | `https://api.asaas.com/v3` | | Sandbox | `https://api-sandbox.asaas.com/v3` | ### Note API keys are distinct between Sandbox and Production environments. Remember to change your API key when switching URLs. ``` -------------------------------- ### Enviar Atualização de Nome para Subconta PJ Source: https://docs.asaas.com/docs/alterar-o-nome-de-uma-subconta-pj-via-api Realize esta requisição POST para atualizar o nome da empresa. O campo `companyName` deve conter exatamente um dos nomes retornados na consulta anterior (`availableCompanyNames`). ```json { "companyName": "NOME ATUALIZADO DA EMPRESA LTDA" } ``` -------------------------------- ### Atualizar notificação existente Source: https://docs.asaas.com/docs/alterando-notificacoes-de-um-cliente Use este endpoint para modificar as configurações de uma notificação específica para um cliente. É necessário o ID da notificação a ser atualizada. ```http POST /v3/notifications/not_000042762599 ``` -------------------------------- ### Authentication Error: Invalid Environment Source: https://docs.asaas.com/docs/autentica%C3%A7%C3%A3o-1 This error occurs when your API key is used in the wrong environment (e.g., production key with sandbox URL). ```APIDOC ## Invalid Environment Error ### Description This error indicates that the provided API key does not belong to the environment you are trying to access. ### Response Example ```json { "errors": [ { "code": "invalid_environment", "description": "A chave de API informada não pertence a este ambiente" } ] } ``` ### Resolution Ensure you are using your Production API key (`$aact_prod_`...) with production endpoints (`api.asaas.com`) and your Sandbox API key (`$aact_hmlg_`...) with Sandbox endpoints (`api-sandbox.asaas.com`). ``` -------------------------------- ### API Key in Wrong Environment Error Source: https://docs.asaas.com/docs/authentication-2 This JSON response indicates that the API key provided is not valid for the current environment (e.g., using a production key in a sandbox environment). Ensure your key matches the endpoint's environment. ```json { "errors": [ { "code": "invalid_environment", "description": "A chave de API informada não pertence a este ambiente" } ] } ``` -------------------------------- ### Required API Request Headers Source: https://docs.asaas.com/docs/authentication-2 Include these headers in all your API calls to Asaas. The 'access_token' should be your API key, and 'User-Agent' is mandatory for new accounts. ```json "Content-Type": "application/json", "User-Agent": "your_app_name", "access_token": "your_api_key" ``` -------------------------------- ### Required API Request Headers Source: https://docs.asaas.com/docs/autentica%C3%A7%C3%A3o-1 Include these headers in all API calls to authenticate your requests. The User-Agent is mandatory for new root accounts created after 13/06/2024. ```json "Content-Type": "application/json", "User-Agent": "nome_da_sua_aplicação", "access_token": "sua_api_key" ``` -------------------------------- ### Batch Update Notification Settings Source: https://docs.asaas.com/docs/alterando-notificacoes-de-um-cliente Allows updating multiple notification settings simultaneously. This is useful for configuring a set of notifications with specific preferences. ```APIDOC ## POST /v3/notifications/batch ### Description Updates notification settings in batch for multiple notification events. ### Method POST ### Endpoint /v3/notifications/batch ### Parameters #### Request Body - **customer** (string) - Required - The ID of the customer associated with these notifications. - **notifications** (array) - Required - A list of notification objects to update. - **id** (string) - Required - The ID of the notification to update. - **enabled** (boolean) - Optional - Whether the notification is enabled overall. - **emailEnabledForProvider** (boolean) - Optional - Whether email notifications are enabled for the provider. - **smsEnabledForProvider** (boolean) - Optional - Whether SMS notifications are enabled for the provider. - **emailEnabledForCustomer** (boolean) - Optional - Whether email notifications are enabled for the customer. - **smsEnabledForCustomer** (boolean) - Optional - Whether SMS notifications are enabled for the customer. - **phoneCallEnabledForCustomer** (boolean) - Optional - Whether phone call notifications are enabled for the customer. - **whatsappEnabledForCustomer** (boolean) - Optional - Whether WhatsApp notifications are enabled for the customer. ### Request Example ```json { "customer": "cus_Y4AEif5zrMGK", "notifications": [ { "id": "not_f8JpoWuEjEKd", "enabled": true, "emailEnabledForProvider": true, "smsEnabledForProvider": true, "emailEnabledForCustomer": true, "smsEnabledForCustomer": true, "phoneCallEnabledForCustomer": false, "whatsappEnabledForCustomer": false }, { "id": "not_f8JpoWuEjEKd", "enabled": true, "emailEnabledForProvider": true, "smsEnabledForProvider": true, "emailEnabledForCustomer": true, "smsEnabledForCustomer": true, "phoneCallEnabledForCustomer": false, "whatsappEnabledForCustomer": false } ] } ``` ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating the batch update was successful. #### Response Example ```json { "message": "Notifications updated successfully." } ``` ``` -------------------------------- ### Authentication Error: Missing Access Token Header Source: https://docs.asaas.com/docs/autentica%C3%A7%C3%A3o-1 This error occurs when the `access_token` header is not included in the request. ```APIDOC ## Missing Access Token Header Error ### Description This error signifies that the required `access_token` authentication header was not found in the request. ### Response Example ```json { "errors": [ { "code": "access_token_not_found", "description": "O cabeçalho de autenticação 'access_token' é obrigatório e não foi encontrado na requisição" } ] } ``` ### Resolution Verify that the `access_token` header is correctly included in all your requests. ``` -------------------------------- ### Authentication Error: Invalid or Revoked API Key Source: https://docs.asaas.com/docs/autentica%C3%A7%C3%A3o-1 This error occurs when the API key is invalid or has been revoked. ```APIDOC ## Invalid or Revoked API Key Error ### Description This error means the API key provided is invalid. ### Response Example ```json { "errors": [ { "code": "invalid_access_token", "description": "A chave de API fornecida é inválida" } ] } ``` ### Resolution Generate a new API key or verify the existing one is active and has not been revoked. ``` -------------------------------- ### Missing Authentication Header Error Source: https://docs.asaas.com/docs/authentication-2 This JSON response signifies that the required 'access_token' authentication header was not found in the request. Always include the 'access_token' header in your API calls. ```json { "errors": [ { "code": "access_token_not_found", "description": "O cabeçalho de autenticação 'access_token' é obrigatório e não foi encontrado na requisição" } ] } ``` -------------------------------- ### Solicitar Antecipação de Cobrança Avulsa Source: https://docs.asaas.com/docs/antecipacoes Use este endpoint para solicitar a antecipação de uma cobrança avulsa. Informe o ID da cobrança no campo 'payment'. ```json { "payment": "pay_626366773834" } ``` -------------------------------- ### Authentication Error: Invalid Access Token Format Source: https://docs.asaas.com/docs/autentica%C3%A7%C3%A3o-1 This error occurs when the provided API key does not match the expected Asaas format. ```APIDOC ## Invalid Access Token Format Error ### Description This error indicates that the provided value does not appear to be a valid Asaas API key. Check the format of your key. ### Response Example ```json { "errors": [ { "code": "invalid_access_token_format", "description": "O valor fornecido não parece ser uma chave de API válida do Asaas. Verifique o formato da sua chave" } ] } ``` ### Resolution Ensure you have not copied extra spaces or characters. Production keys start with `$aact_prod_` and Sandbox keys start with `$aact_hmlg_`. ``` -------------------------------- ### API Authentication Headers Source: https://docs.asaas.com/docs/autentica%C3%A7%C3%A3o-1 All API calls must include the following headers for authentication and identification. ```APIDOC ## API Authentication Headers ### Description It is mandatory to send the `User-Agent` header in all requests for new root accounts created from 13/06/2024. We suggest sending your application's name if your framework does not add a default User-Agent. The User-Agent header helps identify your application in API requests, and customizing it makes it easier to track the origin of calls. ### Headers - `Content-Type`: `application/json` - `User-Agent`: `your_application_name` - `access_token`: `your_api_key` ``` -------------------------------- ### API Endpoint: Update Business Data Source: https://docs.asaas.com/docs/annual-business-data-confirmation-for-subaccounts Use this POST endpoint to submit updated business data for a subaccount. This action is required when business data has expired or needs to be confirmed. Ensure this endpoint is called using the subaccount's specific `access_token`. ```http POST /v3/myAccount/commercialInfo/ ``` -------------------------------- ### Avoid using numbers and special characters in account names Source: https://docs.asaas.com/docs/approval-of-accounts When creating an account, avoid using numbers or special characters in the name field to ensure automatic validation and proper functioning of features like PIX. Prefer using only letters and spaces. ```plaintext Conta Teste_01 ``` ```plaintext Conta Teste Um ``` -------------------------------- ### Webhook Event: Commercial Info Expiring Soon Source: https://docs.asaas.com/docs/annual-business-data-confirmation-for-subaccounts This JSON payload represents a webhook event triggered when a subaccount's commercial information is nearing its expiration date. It includes details about the account status and the scheduled date for expiration. ```json { "id": "evt_05b708f961d739ea7eba7e4db318f621&368604920", "event": "ACCOUNT_STATUS_COMMERCIAL_INFO_EXPIRING_SOON", "dateCreated": "2024-05-10 16:45:03", "accountStatus": { "id": "175027c1-029c-41e5-8b9a-e289b9788c33", "commercialInfo": "APPROVED", "bankAccountInfo": "APPROVED", "documentation": "APPROVED", "general": "APPROVED" }, "additionalInfo": { "scheduledDate": "2025-06-20" } } ``` -------------------------------- ### Invalid or Revoked API Key Error Source: https://docs.asaas.com/docs/authentication-2 This JSON response indicates that the API key used is invalid, has been revoked, or has expired. Confirm the key is correct and active in your Asaas dashboard. ```json { "errors": [ { "code": "invalid_access_token", "description": "A chave de API fornecida é inválida" } ] } ```