Attaches and/or detaches tags on a single patient, addressed by tag NAME so an external system can push its own vocabulary without knowing Luna tag ids.
A name in add that does not exist yet is created in your organization. A name in remove that does not exist is ignored. Removing a tag detaches it from this patient only — the tag itself is kept, because other patients and recall filters may use it.
The call is idempotent: adding a tag the patient already carries, or removing one they do not, succeeds and changes nothing, so a retry after a network failure is always safe.
Names are trimmed and internal whitespace is collapsed; matching is case-sensitive, so "Venta" and "venta" are two different tags. At most 50 names per field. A NEW tag name may be up to 60 characters; an existing longer name — the dashboard does not impose this limit — still resolves, so a tag returned by GET /patient can always be detached. The same name may not appear in both fields.
Returns the tags the patient carries after the change.
Requires an API key with the write scope; keys issued before write access existed are read-only and must be regenerated by an administrator.
Ejemplos de código
Node.js
const fetch = require('node-fetch');
async function llamarApi() {
const claveApi = 'YOUR_API_KEY';
const url = `https://account.lunahealth.app/api/patient/tags`;
const requestBody = {
// Agregue sus datos del cuerpo de la solicitud aquí
};
try {
const response = await fetch(url, {
method: 'POST',
headers: {
'Authorization': `Bearer ${claveApi}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(requestBody)
});
if (!response.ok) {
throw new Error(`API error: ${response.status}`);
}
const data = await response.json();
console.log(data);
return data;
} catch (error) {
console.error('Error al llamar a la API:', error);
throw error;
}
}
llamarApi();
Python
import requests
def llamarApi():
claveApi = 'YOUR_API_KEY'
url = 'https://account.lunahealth.app/api/patient/tags'
headers = {
'Authorization': f'Bearer {claveApi}',
'Content-Type': 'application/json'
}
params = {
}
# Agregue sus datos del cuerpo de la solicitud aquí
request_body = {}
try:
response = requests.post(
url,
headers=headers,
params=params,
json=request_body
)
response.raise_for_status()
data = response.json()
print(data)
return data
except requests.exceptions.RequestException as e:
print(f'Error al llamar a la API: {e}')
raise
llamarApi()
Cuerpo de la solicitud
Requerido
Campos de la solicitud
Nombre
Tipo
Requerido
Descripción
patientId
string
Sí
ID del paciente
add
array<string>
No
Tag names to attach. Created in your organization if new.