Keys
Create, list and revoke the credentials that authenticate your calls.
List API keys
GET/v1/api-keys
This customer's keys, with scopes, profile, status (active, revoked or expired), creation date, last use, revocation and what the account can do with each one (allowedActions).
Query parameters
kindstringoptionalValues:integrationsessionelevation
Responses
200Success.
No fields.
400The body, query or identifier does not match the contract. Each item of campos gives the field and the reason, and the value you sent never comes back. Repeating the same request repeats the refusal.
{
"error": "invalid_request",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Requisição inválida.",
"campos": [
{
"campo": "text.body",
"motivo": "Não pode ficar vazio."
}
]
}401The key is missing, malformed, nonexistent, expired or revoked. The body is always the same, without saying which.
WWW-AuthenticateAlways Bearer.
{
"error": "unauthorized",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Credencial ausente ou inválida."
}403The key lacks the scope the route requires. On a route that opens a number connection, also when the account cannot connect yet (connection_not_released). On the routes that write or send, also when the account is suspended: trial_expired (the free trial ended) or account_blocked (Helsen blocked the account). Suspension does not touch receiving: what arrives is still delivered to your webhook. A test key (mode test) only uses POST /v1/messages and POST /v1/test-mode/inbound-messages; on every other route it receives test_key_not_allowed.
{
"error": "forbidden",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Esta chave não tem o escopo numbers:read, que esta operação exige. Crie uma chave com esse escopo (Integração, Chaves de API, no console) e use-a no lugar desta.",
"requiredScope": "numbers:read"
}{
"error": "test_key_not_allowed",
"docsUrl": "https://lunahia.com.br/docs/modo-de-teste",
"message": "Esta é uma chave de teste: ela só envia mensagem simulada (POST /v1/messages) e pede mensagem recebida simulada (POST /v1/test-mode/inbound-messages). Para esta operação, use uma chave de produção."
}429Too many requests, or a full queue. Wait the time in the Retry-After header and repeat. For POST /v1/messages, repeat with the same Idempotency-Key.
Retry-AfterSeconds to wait before repeating.
{
"error": "rate_limited",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Requisições demais. Tente novamente em instantes."
}503The platform cannot serve right now. Repeat after a few moments, with the same Idempotency-Key when there is one.
{
"error": "unavailable",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Não foi possível concluir a operação agora. Tente novamente em instantes."
}Create an API key
POST/v1/api-keys
Mints a new key and returns the secret exactly once. Store it the moment you receive it, because no route will return it again.
Request body
labelstringoptional1 to 120 charactersscopesarray<string>optionalO que a chave pode fazer, escopo por escopo. Mande scopes ou profile, e nunca os dois: a lista de escopos que cada perfil concede está em GET /v1/api-keys/profiles.at least 1 itemsprofilestringoptionalUm perfil pronto no lugar de scopes: agent (atendimento), full (integração completa) ou read_only (somente leitura). A chave nasce com os escopos que o perfil concede no momento da criação, e a lista deles está em GET /v1/api-keys/profiles.Values:agentfullread_onlyexpiresAtstring (date-time)optionalmodestringoptionallive (o padrão) é a chave de sempre. test cria uma chave do modo de teste: POST /v1/messages com ela NÃO vai à Meta, não usa número seu e não conta na capacidade do plano; a Luna devolve ao seu webhook eventos simulados, assinados e com test: true. Uma chave de teste só usa POST /v1/messages e POST /v1/test-mode/inbound-messages, e não aceita externalId. Não dá para mudar depois: crie outra.Values:livetestexternalIdstringoptionalO seu identificador para o cliente a que esta chave pertence (1 a 128 caracteres), o mesmo externalId do link de conexão e dos números. Com ele, a chave é de UM cliente seu: só lê e envia pelos números com este externalId (inclusive os conectados depois), só cria link com ele, e não lista nem cria endpoints de webhook nem chaves. Sem ele, a chave é da conta inteira. Não dá para mudar depois: crie outra.1 to 128 characters
Responses
201Created.
idstring (uuid)requiredlabelstring | nullrequiredO nome que você deu à chave, para reconhecê-la na lista.kindstringrequiredintegration para chave sua, session para uma sessão do console. elevation é valor histórico, de credenciais emitidas até 10/08/2026, e nenhuma chave nova nasce com ele.Values:integrationsessionelevationscopesarray<string>requiredO que esta chave pode fazer. Uma rota fora deste conjunto responde 403.modestringrequiredlive é a chave de sempre. test é a chave do modo de teste: ela envia mensagem simulada, sem ir à Meta, e só usa POST /v1/messages e POST /v1/test-mode/inbound-messages. Não muda depois da criação. O guia Modo de teste explica.Values:livetestexternalIdstring | nullrequiredO cliente seu a que a chave se restringe, ou nulo na chave da conta. Com valor, a chave só lê e envia pelos números com este externalId, só cria link de conexão com ele, só vê templates e contas das WABAs desses números, e não lista nem cria endpoints de webhook nem chaves. Não muda depois da criação.createdAtstringrequiredexpiresAtstring | nullrequiredNulo em chave de integração: ela vale até ser revogada.revokedAtstring | nullrequiredlastUsedAtstring | nullrequiredO último uso registrado, para identificar chave esquecida.statusstringrequiredactive: a chave vale. revoked: foi revogada (revokedAt diz quando). expired: passou de expiresAt sem ser revogada. Revogada vale mais que expirada. É a API quem decide, e o seu código não precisa comparar datas.Values:activerevokedexpiredprofilestring | nullrequiredO perfil escolhido ao criar a chave (profile em POST /v1/api-keys), ou nulo quando os escopos foram escolhidos um a um e nas chaves anteriores a este campo. É só o rótulo: o que a chave pode fazer é scopes.Values:agentfullread_onlyallowedActionsarray<string>requiredO que a sua conta pode fazer com a chave agora: revoke (POST /v1/api-keys/{id}/revoke), só em chave de integração que ainda vale. Mostre o botão quando o verbo está na lista. Não leva em conta os escopos da chave que perguntou.secretstringrequired
400The body, query or identifier does not match the contract. Each item of campos gives the field and the reason, and the value you sent never comes back. Repeating the same request repeats the refusal.
{
"error": "invalid_request",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Requisição inválida.",
"campos": [
{
"campo": "text.body",
"motivo": "Não pode ficar vazio."
}
]
}401The key is missing, malformed, nonexistent, expired or revoked. The body is always the same, without saying which.
WWW-AuthenticateAlways Bearer.
{
"error": "unauthorized",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Credencial ausente ou inválida."
}403The key lacks the scope the route requires. On a route that opens a number connection, also when the account cannot connect yet (connection_not_released). On the routes that write or send, also when the account is suspended: trial_expired (the free trial ended) or account_blocked (Helsen blocked the account). Suspension does not touch receiving: what arrives is still delivered to your webhook. A test key (mode test) only uses POST /v1/messages and POST /v1/test-mode/inbound-messages; on every other route it receives test_key_not_allowed.
{
"error": "forbidden",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Esta chave não tem o escopo numbers:read, que esta operação exige. Crie uma chave com esse escopo (Integração, Chaves de API, no console) e use-a no lugar desta.",
"requiredScope": "numbers:read"
}{
"error": "trial_expired",
"docsUrl": "https://lunahia.com.br/docs/plano-e-numeros",
"message": "O teste grátis desta conta terminou. O envio de mensagens e as demais escritas estão pausados até a conta ser contratada. Você continua lendo os seus dados, o número segue conectado na Meta e o que chega continua sendo recebido e entregue ao seu webhook. Para continuar, escreva para contato@lunahia.com.br."
}{
"error": "account_blocked",
"docsUrl": "https://lunahia.com.br/docs/plano-e-numeros",
"message": "Esta conta foi bloqueada pela Helsen. O envio de mensagens e as demais escritas estão pausados. Você continua lendo os seus dados, o número segue conectado na Meta e o que chega continua sendo recebido e entregue ao seu webhook. Para saber o motivo e resolver, escreva para contato@lunahia.com.br."
}{
"error": "test_key_not_allowed",
"docsUrl": "https://lunahia.com.br/docs/modo-de-teste",
"message": "Esta é uma chave de teste: ela só envia mensagem simulada (POST /v1/messages) e pede mensagem recebida simulada (POST /v1/test-mode/inbound-messages). Para esta operação, use uma chave de produção."
}415The body came with a content-type the route does not read. Send application/json, or multipart/form-data on the file routes.
{
"error": "unsupported_media_type",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Envie o corpo como application/json."
}429Too many requests, or a full queue. Wait the time in the Retry-After header and repeat. For POST /v1/messages, repeat with the same Idempotency-Key.
Retry-AfterSeconds to wait before repeating.
{
"error": "rate_limited",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Requisições demais. Tente novamente em instantes."
}503The platform cannot serve right now. Repeat after a few moments, with the same Idempotency-Key when there is one.
{
"error": "unavailable",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Não foi possível concluir a operação agora. Tente novamente em instantes."
}List the scopes a key can have
GET/v1/api-keys/scopes
The scopes an integration key can receive, each with its name in Portuguese, what it allows and whether it gives a power that calls for care.
Responses
200Success.
dataarray<object>requireddata[].scopestringrequiredO nome do escopo, o que vai em scopes ao criar a chave.data[].labelstringrequiredO nome da permissão em português.data[].summarystringrequiredO que a permissão deixa fazer.data[].sensitivebooleanrequiredtrue quando a permissão dá um poder que exige cuidado (criar chaves, redirecionar o webhook).
401The key is missing, malformed, nonexistent, expired or revoked. The body is always the same, without saying which.
WWW-AuthenticateAlways Bearer.
{
"error": "unauthorized",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Credencial ausente ou inválida."
}403The key lacks the scope the route requires. On a route that opens a number connection, also when the account cannot connect yet (connection_not_released). On the routes that write or send, also when the account is suspended: trial_expired (the free trial ended) or account_blocked (Helsen blocked the account). Suspension does not touch receiving: what arrives is still delivered to your webhook. A test key (mode test) only uses POST /v1/messages and POST /v1/test-mode/inbound-messages; on every other route it receives test_key_not_allowed.
{
"error": "forbidden",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Esta chave não tem o escopo numbers:read, que esta operação exige. Crie uma chave com esse escopo (Integração, Chaves de API, no console) e use-a no lugar desta.",
"requiredScope": "numbers:read"
}{
"error": "test_key_not_allowed",
"docsUrl": "https://lunahia.com.br/docs/modo-de-teste",
"message": "Esta é uma chave de teste: ela só envia mensagem simulada (POST /v1/messages) e pede mensagem recebida simulada (POST /v1/test-mode/inbound-messages). Para esta operação, use uma chave de produção."
}429Too many requests, or a full queue. Wait the time in the Retry-After header and repeat. For POST /v1/messages, repeat with the same Idempotency-Key.
Retry-AfterSeconds to wait before repeating.
{
"error": "rate_limited",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Requisições demais. Tente novamente em instantes."
}503The platform cannot serve right now. Repeat after a few moments, with the same Idempotency-Key when there is one.
{
"error": "unavailable",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Não foi possível concluir a operação agora. Tente novamente em instantes."
}List the key profiles
GET/v1/api-keys/profiles
The ready-made key profiles (agent, full and read_only) and the scopes each one grants. In POST /v1/api-keys, profile stands in for scopes.
Responses
200Success.
dataarray<object>requireddata[].idstringrequiredO que vai em profile ao criar a chave.Values:agentfullread_onlydata[].labelstringrequireddata[].summarystringrequiredO que a chave deste perfil permite, em uma frase.data[].scopesarray<string>requiredOs escopos que o perfil concede hoje.
401The key is missing, malformed, nonexistent, expired or revoked. The body is always the same, without saying which.
WWW-AuthenticateAlways Bearer.
{
"error": "unauthorized",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Credencial ausente ou inválida."
}403The key lacks the scope the route requires. On a route that opens a number connection, also when the account cannot connect yet (connection_not_released). On the routes that write or send, also when the account is suspended: trial_expired (the free trial ended) or account_blocked (Helsen blocked the account). Suspension does not touch receiving: what arrives is still delivered to your webhook. A test key (mode test) only uses POST /v1/messages and POST /v1/test-mode/inbound-messages; on every other route it receives test_key_not_allowed.
{
"error": "forbidden",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Esta chave não tem o escopo numbers:read, que esta operação exige. Crie uma chave com esse escopo (Integração, Chaves de API, no console) e use-a no lugar desta.",
"requiredScope": "numbers:read"
}{
"error": "test_key_not_allowed",
"docsUrl": "https://lunahia.com.br/docs/modo-de-teste",
"message": "Esta é uma chave de teste: ela só envia mensagem simulada (POST /v1/messages) e pede mensagem recebida simulada (POST /v1/test-mode/inbound-messages). Para esta operação, use uma chave de produção."
}429Too many requests, or a full queue. Wait the time in the Retry-After header and repeat. For POST /v1/messages, repeat with the same Idempotency-Key.
Retry-AfterSeconds to wait before repeating.
{
"error": "rate_limited",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Requisições demais. Tente novamente em instantes."
}503The platform cannot serve right now. Repeat after a few moments, with the same Idempotency-Key when there is one.
{
"error": "unavailable",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Não foi possível concluir a operação agora. Tente novamente em instantes."
}Read one API key
GET/v1/api-keys/{id}
One key's metadata. The secret does not come back, for the reason described on the listing route.
Path parameters
idstring (uuid)required
Responses
200Success.
idstring (uuid)requiredlabelstring | nullrequiredO nome que você deu à chave, para reconhecê-la na lista.kindstringrequiredintegration para chave sua, session para uma sessão do console. elevation é valor histórico, de credenciais emitidas até 10/08/2026, e nenhuma chave nova nasce com ele.Values:integrationsessionelevationscopesarray<string>requiredO que esta chave pode fazer. Uma rota fora deste conjunto responde 403.modestringrequiredlive é a chave de sempre. test é a chave do modo de teste: ela envia mensagem simulada, sem ir à Meta, e só usa POST /v1/messages e POST /v1/test-mode/inbound-messages. Não muda depois da criação. O guia Modo de teste explica.Values:livetestexternalIdstring | nullrequiredO cliente seu a que a chave se restringe, ou nulo na chave da conta. Com valor, a chave só lê e envia pelos números com este externalId, só cria link de conexão com ele, só vê templates e contas das WABAs desses números, e não lista nem cria endpoints de webhook nem chaves. Não muda depois da criação.createdAtstringrequiredexpiresAtstring | nullrequiredNulo em chave de integração: ela vale até ser revogada.revokedAtstring | nullrequiredlastUsedAtstring | nullrequiredO último uso registrado, para identificar chave esquecida.statusstringrequiredactive: a chave vale. revoked: foi revogada (revokedAt diz quando). expired: passou de expiresAt sem ser revogada. Revogada vale mais que expirada. É a API quem decide, e o seu código não precisa comparar datas.Values:activerevokedexpiredprofilestring | nullrequiredO perfil escolhido ao criar a chave (profile em POST /v1/api-keys), ou nulo quando os escopos foram escolhidos um a um e nas chaves anteriores a este campo. É só o rótulo: o que a chave pode fazer é scopes.Values:agentfullread_onlyallowedActionsarray<string>requiredO que a sua conta pode fazer com a chave agora: revoke (POST /v1/api-keys/{id}/revoke), só em chave de integração que ainda vale. Mostre o botão quando o verbo está na lista. Não leva em conta os escopos da chave que perguntou.
400The body, query or identifier does not match the contract. Each item of campos gives the field and the reason, and the value you sent never comes back. Repeating the same request repeats the refusal.
{
"error": "invalid_request",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Requisição inválida.",
"campos": [
{
"campo": "text.body",
"motivo": "Não pode ficar vazio."
}
]
}401The key is missing, malformed, nonexistent, expired or revoked. The body is always the same, without saying which.
WWW-AuthenticateAlways Bearer.
{
"error": "unauthorized",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Credencial ausente ou inválida."
}403The key lacks the scope the route requires. On a route that opens a number connection, also when the account cannot connect yet (connection_not_released). On the routes that write or send, also when the account is suspended: trial_expired (the free trial ended) or account_blocked (Helsen blocked the account). Suspension does not touch receiving: what arrives is still delivered to your webhook. A test key (mode test) only uses POST /v1/messages and POST /v1/test-mode/inbound-messages; on every other route it receives test_key_not_allowed.
{
"error": "forbidden",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Esta chave não tem o escopo numbers:read, que esta operação exige. Crie uma chave com esse escopo (Integração, Chaves de API, no console) e use-a no lugar desta.",
"requiredScope": "numbers:read"
}{
"error": "test_key_not_allowed",
"docsUrl": "https://lunahia.com.br/docs/modo-de-teste",
"message": "Esta é uma chave de teste: ela só envia mensagem simulada (POST /v1/messages) e pede mensagem recebida simulada (POST /v1/test-mode/inbound-messages). Para esta operação, use uma chave de produção."
}404The resource does not exist, or is not yours. The two answers are identical, byte for byte.
{
"error": "not_found",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Recurso não encontrado."
}429Too many requests, or a full queue. Wait the time in the Retry-After header and repeat. For POST /v1/messages, repeat with the same Idempotency-Key.
Retry-AfterSeconds to wait before repeating.
{
"error": "rate_limited",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Requisições demais. Tente novamente em instantes."
}503The platform cannot serve right now. Repeat after a few moments, with the same Idempotency-Key when there is one.
{
"error": "unavailable",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Não foi possível concluir a operação agora. Tente novamente em instantes."
}Revoke an API key
POST/v1/api-keys/{id}/revoke
Invalidates the key immediately. The operation is idempotent, so revoking again returns the same result without an error.
Path parameters
idstring (uuid)required
Responses
200Success.
idstring (uuid)requiredlabelstring | nullrequiredO nome que você deu à chave, para reconhecê-la na lista.kindstringrequiredintegration para chave sua, session para uma sessão do console. elevation é valor histórico, de credenciais emitidas até 10/08/2026, e nenhuma chave nova nasce com ele.Values:integrationsessionelevationscopesarray<string>requiredO que esta chave pode fazer. Uma rota fora deste conjunto responde 403.modestringrequiredlive é a chave de sempre. test é a chave do modo de teste: ela envia mensagem simulada, sem ir à Meta, e só usa POST /v1/messages e POST /v1/test-mode/inbound-messages. Não muda depois da criação. O guia Modo de teste explica.Values:livetestexternalIdstring | nullrequiredO cliente seu a que a chave se restringe, ou nulo na chave da conta. Com valor, a chave só lê e envia pelos números com este externalId, só cria link de conexão com ele, só vê templates e contas das WABAs desses números, e não lista nem cria endpoints de webhook nem chaves. Não muda depois da criação.createdAtstringrequiredexpiresAtstring | nullrequiredNulo em chave de integração: ela vale até ser revogada.revokedAtstring | nullrequiredlastUsedAtstring | nullrequiredO último uso registrado, para identificar chave esquecida.statusstringrequiredactive: a chave vale. revoked: foi revogada (revokedAt diz quando). expired: passou de expiresAt sem ser revogada. Revogada vale mais que expirada. É a API quem decide, e o seu código não precisa comparar datas.Values:activerevokedexpiredprofilestring | nullrequiredO perfil escolhido ao criar a chave (profile em POST /v1/api-keys), ou nulo quando os escopos foram escolhidos um a um e nas chaves anteriores a este campo. É só o rótulo: o que a chave pode fazer é scopes.Values:agentfullread_onlyallowedActionsarray<string>requiredO que a sua conta pode fazer com a chave agora: revoke (POST /v1/api-keys/{id}/revoke), só em chave de integração que ainda vale. Mostre o botão quando o verbo está na lista. Não leva em conta os escopos da chave que perguntou.
400The body, query or identifier does not match the contract. Each item of campos gives the field and the reason, and the value you sent never comes back. Repeating the same request repeats the refusal.
{
"error": "invalid_request",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Requisição inválida.",
"campos": [
{
"campo": "text.body",
"motivo": "Não pode ficar vazio."
}
]
}401The key is missing, malformed, nonexistent, expired or revoked. The body is always the same, without saying which.
WWW-AuthenticateAlways Bearer.
{
"error": "unauthorized",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Credencial ausente ou inválida."
}403The key lacks the scope the route requires. On a route that opens a number connection, also when the account cannot connect yet (connection_not_released). On the routes that write or send, also when the account is suspended: trial_expired (the free trial ended) or account_blocked (Helsen blocked the account). Suspension does not touch receiving: what arrives is still delivered to your webhook. A test key (mode test) only uses POST /v1/messages and POST /v1/test-mode/inbound-messages; on every other route it receives test_key_not_allowed.
{
"error": "forbidden",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Esta chave não tem o escopo numbers:read, que esta operação exige. Crie uma chave com esse escopo (Integração, Chaves de API, no console) e use-a no lugar desta.",
"requiredScope": "numbers:read"
}{
"error": "test_key_not_allowed",
"docsUrl": "https://lunahia.com.br/docs/modo-de-teste",
"message": "Esta é uma chave de teste: ela só envia mensagem simulada (POST /v1/messages) e pede mensagem recebida simulada (POST /v1/test-mode/inbound-messages). Para esta operação, use uma chave de produção."
}404The resource does not exist, or is not yours. The two answers are identical, byte for byte.
{
"error": "not_found",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Recurso não encontrado."
}429Too many requests, or a full queue. Wait the time in the Retry-After header and repeat. For POST /v1/messages, repeat with the same Idempotency-Key.
Retry-AfterSeconds to wait before repeating.
{
"error": "rate_limited",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Requisições demais. Tente novamente em instantes."
}503The platform cannot serve right now. Repeat after a few moments, with the same Idempotency-Key when there is one.
{
"error": "unavailable",
"docsUrl": "https://lunahia.com.br/docs/erros",
"message": "Não foi possível concluir a operação agora. Tente novamente em instantes."
}