Quick Start - Sindri REST API
1. Autenticacao
JWT (usuarios interativos)
Login
curl -X POST http://localhost:8000/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"username": "admin", "password": "secret"}'
Response: {"access_token": "eyJ...", "token_type": "bearer", "expires_in": 3600}
Usar token
curl -H "Authorization: Bearer eyJ..." http://localhost:8000/api/v1/system/health
API Key (automacao M2M)
Criar API key (requer JWT admin)
curl -X POST http://localhost:8000/api/v1/auth/api-keys \
-H "Authorization: Bearer $ADMIN_TOKEN" \
-d '{"name": "ci-pipeline-runner", "permissions": ["pipelines:run", "storage:list"]}'
Response: {"key": "tdv_sk_abc123...", "key_id": "uuid-here"}
Usar API key
curl -H "X-API-Key: tdv_sk_abc123..." http://localhost:8000/api/v1/pipelines
2. Primeiro Pipeline
Validar enviando o CONTEUDO do YAML (funciona com o servidor em outra maquina)
curl -X POST http://localhost:8000/api/v1/pipelines/validate \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "{"pipeline_yaml": $(jq -Rs . < pipeline.yaml)}"
Upload do YAML
curl -X POST http://localhost:8000/api/v1/storage/upload \
-H "Authorization: Bearer $TOKEN" \
-F "file=@pipeline.yaml" \
-F "artifact_type=pipeline"
Executar (async): a execucao usa REFERENCIA relativa ao root governado pelo
servidor (TDV_API_PIPELINE_ROOT + TDV_API_LOCAL_FS=true). Path absoluto ou com
".." e recusado; sem root declarado, nenhuma referencia por path e aceita.
curl -X POST http://localhost:8000/api/v1/jobs/pipelines/run \
-H "Authorization: Bearer $TOKEN" \
-d '{"config_path": "pipelines/pipeline.yaml"}'
Response: {"job_id": "job-uuid", "status": "queued"}
Monitorar progresso (SSE stream)
curl -N http://localhost:8000/api/v1/jobs/job-uuid/events \
-H "Authorization: Bearer $TOKEN"
Verificar resultado
curl http://localhost:8000/api/v1/jobs/job-uuid \
-H "Authorization: Bearer $TOKEN"
3. Validacao de Dados (dbt-style)
POST /api/v1/validation/dbt-test — executa data tests no estilo dbt
curl -X POST http://localhost:8000/api/v1/validation/dbt-test \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"config_path": "validation/dbt_project"}'
4. Analytics (Data Intelligence)
POST /api/v1/data/classify — classifica colunas como dimensao ou medida BI
curl -X POST http://localhost:8000/api/v1/data/classify \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"dataset": "gold.vendas"}'
5. Agendamento
Criar schedule
curl -X POST http://localhost:8000/api/v1/schedules \
-H "Authorization: Bearer $TOKEN" \
-d '{"pipeline": "etl.yaml", "cron": "0 8 * * MON-FRI", "name": "daily-etl"}'
Listar
curl http://localhost:8000/api/v1/schedules \
-H "Authorization: Bearer $TOKEN"
Headers Importantes
| Header | Uso |
Authorization: Bearer | JWT auth |
X-API-Key: tdv_sk_... | API key auth (alternativo) |
claim JWT tenant_id no Bearer token | Multi-tenant (derivado do token, verificado) |
Idempotency-Key: uuid | Previne execucao duplicada em POST |
Error Handling
Erros seguem RFC 7807 Problem Details:
{
"type": "https://docs.tdv.io/errors/TDV-6001",
"title": "Step Execution Failed",
"status": 422,
"detail": "Step 'extract_oracle' falhou: connection timeout",
"error_code": "TDV-6001",
"retryable": true,
"context": {"step": "extract_oracle", "attempt": 3}
}
Consulte GET /api/v1/system/errors para catalogo completo de error codes.