# Consulta de alterações de medicamentos e fontes

Sincronize sua integração pelo feed /v1/changes, usando since e next_cursor sem confundir mudanças de fonte com conclusões regulatórias.

Canonical: https://iabula.com/docs/changes

## Leia mudanças publicadas

GET /v1/changes retorna eventos publicados com data e next_cursor. Na primeira consulta, omita since. limit aceita de 1 a 100 com padrão 50. A ordenação por occurred_at e UUID fornece paginação estável no histórico disponível.

```bash
curl --fail-with-body --get "$IABULA_API_BASE/v1/changes" \
  --header "X-API-Key: $IABULA_API_KEY" \
  --data-urlencode "limit=50"
```

## Continue com since

Envie o next_cursor recebido como since na chamada seguinte. Preserve o cursor mesmo após data vir vazia para continuar o polling mais tarde. Não reutilize cursores de busca neste feed. Um consumidor deve persistir o cursor apenas depois de processar os eventos com sucesso.

```bash
curl --fail-with-body --get "$IABULA_API_BASE/v1/changes" \
  --header "X-API-Key: $IABULA_API_KEY" \
  --data-urlencode "since=$IABULA_CURSOR" \
  --data-urlencode "limit=50"
```

## Mudança observada não é conclusão clínica

Eventos canônicos usam created, updated ou withdrawn. Comparações de fontes podem usar observed_in_source, changed_in_source e removed_from_source. A interpretação depende de entity_type, before, after e evidence.

> removed_from_source descreve a ausência de uma observação no recurso comparado. Não significa retirada de medicamento do mercado, cancelamento de registro ou qualquer conclusão clínica.

## Sincronização defensiva

Use o ID do evento para evitar processamento duplicado em sua integração. Leia a evidência de fonte, versão, URL, source_record_id e source_run_id quando disponíveis. A entrega é por consulta HTTP; não há webhook de alterações documentado no V1.

- [Erros e limites](https://iabula.com/docs/errors)
- [Dados CMED e proveniência](https://iabula.com/docs/provenance)

## GET /v1/changes

| Parâmetro | Local | Obrigatório | Tipo e limites |
| --- | --- | --- | --- |
| since | query | no | string; maxLength=2048 \| null |
| limit | query | no | integer; minimum=1, maximum=100, default=50 |

| HTTP | Content-Type | Schema |
| --- | --- | --- |
| 200 | application/json | ChangePage |
| 400 | application/json | Problem |
| 401 | application/json | Problem |
| 403 | application/json | Problem |
| 429 | application/json | Problem |
| 500 | application/json | Problem |
| 503 | application/json | Problem |
| 422 | application/json | HTTPValidationError |

## Campos do contrato OpenAPI

| Schema.campo | Tipo e limites | Obrigatório |
| --- | --- | --- |
| ChangeEvidence.class | string | yes |
| ChangeEvidence.source | string \| null | no |
| ChangeEvidence.dataset | string \| null | no |
| ChangeEvidence.retrieved_at | string (date-time) \| null | no |
| ChangeEvidence.source_version | string | yes |
| ChangeEvidence.source_record_id | string \| null | no |
| ChangeEvidence.source_run_id | string \| null | no |
| ChangeEvidence.attribute | string \| null | no |
| ChangeEvidence.rule_version | string \| null | no |
| ChangeEvidence.source_url | string | yes |
| ChangePage.data | array<ChangeRecord> | yes |
| ChangePage.next_cursor | string \| null | yes |
| ChangeRecord.id | string (uuid) | yes |
| ChangeRecord.entity_type | string | yes |
| ChangeRecord.entity_id | string (uuid) | yes |
| ChangeRecord.operation | string: created, updated, withdrawn, observed_in_source, changed_in_source, removed_from_source | yes |
| ChangeRecord.before | object \| null | no |
| ChangeRecord.after | object \| null | no |
| ChangeRecord.occurred_at | string (date-time) | yes |
| ChangeRecord.evidence | ChangeEvidence | yes |
| HTTPValidationError.detail | array<ValidationError> | no |
| Problem.type | string | yes |
| Problem.title | string | yes |
| Problem.status | integer | yes |
| Problem.code | string | yes |
| Problem.detail | string \| null | no |
| Problem.request_id | string | yes |
| ValidationError.loc | array<string \| integer> | yes |
| ValidationError.msg | string | yes |
| ValidationError.type | string | yes |
| ValidationError.input | object | no |
| ValidationError.ctx | object | no |

## Recursos

- [OpenAPI JSON](https://iabula.com/openapi.json)
- [Swagger](https://iabula.com/docs/swagger)
- [Documentation index](https://iabula.com/llms.txt)
