Configurar organización de facturación (Facturapi)
POST
/invoices/setup-org
const url = 'https://api.dev.lade.com.mx/invoices/setup-org';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"teamId":"550e8400-e29b-41d4-a716-446655440000"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.dev.lade.com.mx/invoices/setup-org \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "teamId": "550e8400-e29b-41d4-a716-446655440000" }'Crea la organización del equipo en Facturapi y obtiene sus API keys (test y live). Idempotente: si la organización ya existe, solo se asegura de que las API keys estén guardadas. Requiere rol OWNER o ADMIN. La API key live puede fallar en emitirse hasta que los datos fiscales y el CSD estén completos — /invoices/certificate reintenta esto automáticamente.
Authorizations
Sección titulada «Authorizations»Request Bodyrequired
Sección titulada «Request Bodyrequired»Media typeapplication/json
object
teamId
required
string format: uuid
Example
{ "teamId": "550e8400-e29b-41d4-a716-446655440000"}Responses
Sección titulada «Responses»La organización ya existía (idempotente)
Media typeapplication/json
object
message
string
orgId
string
Example
{ "message": "Organization already exists", "orgId": "5f8a1b2c3d4e5f6a7b8c9d0e"}Organización creada en Facturapi
Media typeapplication/json
object
message
string
orgId
string
Example
{ "message": "Organization created successfully", "orgId": "5f8a1b2c3d4e5f6a7b8c9d0e"}Solicitud inválida
Media typeapplication/json
object
error
required
string
message
string
field
string
Example
{ "error": "Validation failed", "field": "email", "message": "Invalid email format"}Sin permisos
Media typeapplication/json
object
error
required
string
message
string
field
string
Example
{ "error": "Forbidden", "message": "You don't have permission to access this resource"}Recurso no encontrado
Media typeapplication/json
object
error
required
string
message
string
field
string
Example
{ "error": "Not found", "message": "Resource not found"}Error al comunicarse con el proveedor externo (Facturapi/Stripe)
Media typeapplication/json
object
error
required
string
message
string
field
string
Example
{ "error": "Facturapi error: the CSD certificate is invalid"}