curl --request POST \
--url https://api.athenahq.ai/api/v1/invites \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"type": "organization",
"invite_method": "email",
"email": "user@example.com",
"role": "viewer",
"role_id": "789e0123-e89b-12d3-a456-426614174000",
"website_id": "123e4567-e89b-12d3-a456-426614174000",
"group_id": "456e7890-e89b-12d3-a456-426614174000",
"first_name": "John",
"last_name": "Doe"
}
'import requests
url = "https://api.athenahq.ai/api/v1/invites"
payload = {
"type": "organization",
"invite_method": "email",
"email": "user@example.com",
"role": "viewer",
"role_id": "789e0123-e89b-12d3-a456-426614174000",
"website_id": "123e4567-e89b-12d3-a456-426614174000",
"group_id": "456e7890-e89b-12d3-a456-426614174000",
"first_name": "John",
"last_name": "Doe"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
type: 'organization',
invite_method: 'email',
email: 'user@example.com',
role: 'viewer',
role_id: '789e0123-e89b-12d3-a456-426614174000',
website_id: '123e4567-e89b-12d3-a456-426614174000',
group_id: '456e7890-e89b-12d3-a456-426614174000',
first_name: 'John',
last_name: 'Doe'
})
};
fetch('https://api.athenahq.ai/api/v1/invites', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.athenahq.ai/api/v1/invites",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'type' => 'organization',
'invite_method' => 'email',
'email' => 'user@example.com',
'role' => 'viewer',
'role_id' => '789e0123-e89b-12d3-a456-426614174000',
'website_id' => '123e4567-e89b-12d3-a456-426614174000',
'group_id' => '456e7890-e89b-12d3-a456-426614174000',
'first_name' => 'John',
'last_name' => 'Doe'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.athenahq.ai/api/v1/invites"
payload := strings.NewReader("{\n \"type\": \"organization\",\n \"invite_method\": \"email\",\n \"email\": \"user@example.com\",\n \"role\": \"viewer\",\n \"role_id\": \"789e0123-e89b-12d3-a456-426614174000\",\n \"website_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"group_id\": \"456e7890-e89b-12d3-a456-426614174000\",\n \"first_name\": \"John\",\n \"last_name\": \"Doe\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.athenahq.ai/api/v1/invites")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"type\": \"organization\",\n \"invite_method\": \"email\",\n \"email\": \"user@example.com\",\n \"role\": \"viewer\",\n \"role_id\": \"789e0123-e89b-12d3-a456-426614174000\",\n \"website_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"group_id\": \"456e7890-e89b-12d3-a456-426614174000\",\n \"first_name\": \"John\",\n \"last_name\": \"Doe\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.athenahq.ai/api/v1/invites")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"type\": \"organization\",\n \"invite_method\": \"email\",\n \"email\": \"user@example.com\",\n \"role\": \"viewer\",\n \"role_id\": \"789e0123-e89b-12d3-a456-426614174000\",\n \"website_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"group_id\": \"456e7890-e89b-12d3-a456-426614174000\",\n \"first_name\": \"John\",\n \"last_name\": \"Doe\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "User added to organization",
"user_id": "abc12345-e89b-12d3-a456-426614174000"
}Crear invitación
Invita a un usuario a tu organización, un sitio concreto o un grupo. invite_method: "direct" lo añade inmediatamente sin correo; si no existe la cuenta, se crea automáticamente. invite_method: "email" crea una invitación pendiente y envía un correo que debe aceptar. Los grupos requieren una clave global. Una invitación con clave limitada al sitio exige además que su creador sea administrador del sitio. Una invitación directa no puede crear cuentas con dominios de correo de Cuba, Irán, Corea del Norte, Rusia, Bielorrusia o dominios regionales de Crimea (incluida Sebastopol), Donetsk o Lugansk; devuelve HTTP 400 con error. Los dominios generales .ua siguen permitidos. Se puede seguir invitando a cuentas existentes.
curl --request POST \
--url https://api.athenahq.ai/api/v1/invites \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"type": "organization",
"invite_method": "email",
"email": "user@example.com",
"role": "viewer",
"role_id": "789e0123-e89b-12d3-a456-426614174000",
"website_id": "123e4567-e89b-12d3-a456-426614174000",
"group_id": "456e7890-e89b-12d3-a456-426614174000",
"first_name": "John",
"last_name": "Doe"
}
'import requests
url = "https://api.athenahq.ai/api/v1/invites"
payload = {
"type": "organization",
"invite_method": "email",
"email": "user@example.com",
"role": "viewer",
"role_id": "789e0123-e89b-12d3-a456-426614174000",
"website_id": "123e4567-e89b-12d3-a456-426614174000",
"group_id": "456e7890-e89b-12d3-a456-426614174000",
"first_name": "John",
"last_name": "Doe"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
type: 'organization',
invite_method: 'email',
email: 'user@example.com',
role: 'viewer',
role_id: '789e0123-e89b-12d3-a456-426614174000',
website_id: '123e4567-e89b-12d3-a456-426614174000',
group_id: '456e7890-e89b-12d3-a456-426614174000',
first_name: 'John',
last_name: 'Doe'
})
};
fetch('https://api.athenahq.ai/api/v1/invites', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.athenahq.ai/api/v1/invites",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'type' => 'organization',
'invite_method' => 'email',
'email' => 'user@example.com',
'role' => 'viewer',
'role_id' => '789e0123-e89b-12d3-a456-426614174000',
'website_id' => '123e4567-e89b-12d3-a456-426614174000',
'group_id' => '456e7890-e89b-12d3-a456-426614174000',
'first_name' => 'John',
'last_name' => 'Doe'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.athenahq.ai/api/v1/invites"
payload := strings.NewReader("{\n \"type\": \"organization\",\n \"invite_method\": \"email\",\n \"email\": \"user@example.com\",\n \"role\": \"viewer\",\n \"role_id\": \"789e0123-e89b-12d3-a456-426614174000\",\n \"website_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"group_id\": \"456e7890-e89b-12d3-a456-426614174000\",\n \"first_name\": \"John\",\n \"last_name\": \"Doe\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.athenahq.ai/api/v1/invites")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"type\": \"organization\",\n \"invite_method\": \"email\",\n \"email\": \"user@example.com\",\n \"role\": \"viewer\",\n \"role_id\": \"789e0123-e89b-12d3-a456-426614174000\",\n \"website_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"group_id\": \"456e7890-e89b-12d3-a456-426614174000\",\n \"first_name\": \"John\",\n \"last_name\": \"Doe\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.athenahq.ai/api/v1/invites")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"type\": \"organization\",\n \"invite_method\": \"email\",\n \"email\": \"user@example.com\",\n \"role\": \"viewer\",\n \"role_id\": \"789e0123-e89b-12d3-a456-426614174000\",\n \"website_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"group_id\": \"456e7890-e89b-12d3-a456-426614174000\",\n \"first_name\": \"John\",\n \"last_name\": \"Doe\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "User added to organization",
"user_id": "abc12345-e89b-12d3-a456-426614174000"
}Cuerpo
Cuerpo de la solicitud para crear una invitación
Tipo de invitación. 'organization' concede acceso a toda la organización; 'website', a un sitio web; 'group', a todos los sitios de un grupo. Las invitaciones a grupos requieren una clave de API global.
organization, website, group "organization"
Cómo invitar al usuario. 'direct' lo añade inmediatamente al recurso sin correo; si no existe la cuenta, la crea automáticamente (con emailVerified=false) y añade la pertenencia. 'email' crea una invitación pendiente y envía un correo mediante Postmark; el usuario debe aceptarlo para acceder.
direct, email "email"
Dirección de correo del usuario al que invitar
"user@example.com"
Rol que se asignará al usuario invitado. Mutuamente excluyente con role_id.
admin, viewer "viewer"
Asigna cualquier rol por ID, del sistema o personalizado de tu organización (consulta GET /api/v1/roles). Excluyente con role. Devuelve 404 si no existe o pertenece a otra organización. Por defecto usa Viewer si no se indica ni role ni role_id. Los ID de roles del sistema son centinelas con formato GUID (p. ej., 00000000-0000-0000-0000-000000000001), no UUID RFC 4122.
^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"789e0123-e89b-12d3-a456-426614174000"
Obligatorio cuando type es 'website'. ID del sitio web al que se concederá acceso
"123e4567-e89b-12d3-a456-426614174000"
Obligatorio cuando type es 'group'. ID del grupo al que se concederá acceso. Requiere una clave de API global.
"456e7890-e89b-12d3-a456-426614174000"
Nombre opcional del usuario invitado. Se utiliza al crear una cuenta en invitaciones 'direct' o al completar el registro de invitación en invitaciones 'email'.
"John"
Apellido opcional del usuario invitado. Se utiliza al crear una cuenta en invitaciones 'direct' o al completar el registro de invitación en invitaciones 'email'.
"Doe"
Respuesta
Usuario añadido o invitación enviada correctamente
Respuesta de la creación de una invitación
Indica si la operación se ha completado correctamente
true
Un mensaje que describe el resultado
"Invitation sent"
ID de la invitación creada (solo aparece en invitaciones por correo)
"123e4567-e89b-12d3-a456-426614174000"
ID del usuario destinatario. Solo aparece en invitaciones directas (el usuario se busca o crea inmediatamente). Nunca se devuelve en invitaciones por correo para impedir averiguar si existen cuentas de otras organizaciones.
"abc12345-e89b-12d3-a456-426614174000"
¿Esta página le ayudó?