> For the complete documentation index, see [llms.txt](https://docs.yoplanning.support/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yoplanning.support/pt/developpeur/tutoriel-dacces-au-catalogue/verification-de-la-disponibilite-via-lapi-yoplanning.md).

# Verificando a disponibilidade através da API do Yoplanning

**Endpoint: /api/v3.1/teams/\[teamId]/order-validation**

Este método da API permite verificar se os itens do carrinho de compras ainda estão disponíveis antes da finalização do pedido. É particularmente útil para evitar situações de overbooking quando muitos clientes fazem reservas simultaneamente.

***

**Exemplo de uso com CURL**

**Ponto final:**

```
/api/v3.1/teams/[teamId]/order-validation
```

**Descrição :**

Você deve enviar o mesmo JSON usado para fazer o pedido, sendo a única diferença a URL.

**Exemplo :**

```bash
curl -H "Content-Type: application/json" -X POST -d '{
    "external_reference" : "956",
    "items" : [{
        "session_group" : "53071a97-0c2d-4973-89f5-cafd10665b3b",
        "price" : {"amount" : 51.25},
        "client" : {
            "id" : "71ea849f-226c-4302-a433-528179634aa7",
            "first_name" : "John",
            "last_name" : "Doe",
            "email" : "john.doe@gmail.com"
        }
    }],
    "payments" : [{
        "amount" : 51.25,
        "client" : {
            "first_name" : "Framold",
            "last_name" : "Doe",
            "email" : "john.doe@gmail.com"
        }
    }]
}' https://yoplanning.pro/api/v3.1/teams/5a90332e-568f-4980-9859-88a984844a4d/order-validation -H 'Authorization: Token 4504c2cb0d87a93106d4de029f407c86149f2ada'
```

**Responder, se disponível:**

```json
{
    "success": true
}
```

**Resposta em caso de indisponibilidade:**

```json
{
    "success": false, 
    "unavailable_items": {
        "group_ids": ["2265cac0-cba5-46eb-8095-b89f93e7473f"], 
        "dry_resource_ids": [], 
        "voucher_ids": [], 
        "resources": []
    }
}
```

***

**Dicas de utilização e boas práticas**

1. **Verificação antes da finalização de cada pedido:** Utilize este método antes de finalizar um pedido para garantir que todos os recursos necessários ainda estejam disponíveis.
2. **Gestão de erros:** Em caso de indisponibilidade, planeje uma gestão de erros adequada para informar o cliente e oferecer alternativas.
3. **Automação:** Integre essa verificação em um processo automatizado para transações em tempo real, especialmente durante períodos de alta atividade.

***

**Erros Comuns e Soluções**

1. **Erro 404 (Não encontrado):**
   * **Causa:** Ponto de extremidade inválido ou ID da equipe incorreto.
   * **Solução:** Verifique o URL e o ID da equipe utilizados.
2. **Erro 401 (Não autorizado):**
   * **Causa:** Problema de autenticação.
   * **Solução:** Verifique o token de autenticação e certifique-se de que ele seja válido e esteja ativo.
3. **Erro 400 (Solicitação Inválida):**
   * **Causa:** Formato JSON incorreto ou dados ausentes.
   * **Solução:** Verifique se o JSON enviado está formatado corretamente e se todas as informações necessárias estão incluídas.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.yoplanning.support/pt/developpeur/tutoriel-dacces-au-catalogue/verification-de-la-disponibilite-via-lapi-yoplanning.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
