> 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/en/developpeur/tutoriel-dacces-au-catalogue/verification-de-la-disponibilite-via-lapi-yoplanning.md).

# Vérification de la Disponibilité via l'API Yoplanning

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

This API method allows you to check if the contents of the cart are still available before finalizing the order. It is particularly useful to avoid overbooking situations in cases where many customers make reservations simultaneously.

***

**Example of use with CURL**

**Endpoint:**

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

**Description :**

You must send the same JSON used to place an order, the only difference being the URL.

**Example :**

```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'
```

**Response in case of availability:**

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

**Response in case of unavailability:**

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

***

**Tips for use and best practices**

1. **Check before each order finalization:** Use this method before finalizing an order to ensure that all necessary resources are still available.
2. **Error management:** In the event of unavailability, provide appropriate error management to inform the customer and offer alternatives.
3. **Automation:** Integrate this verification into an automated process for real-time transactions, especially during periods of high activity.

***

**Common errors and solutions**

1. **Error 404 (Not Found):**
   * **Cause:** Bad endpoint or incorrect teamId.
   * **Solution:** Check the URL and the teamId used.
2. **Error 401 (Unauthorized):**
   * **Cause:** Authentication problem.
   * **Solution:** Check the authentication token and ensure that it is valid and active.
3. **Error 400 (Bad Request):**
   * **Cause:** Incorrect JSON format or missing data.
   * **Solution:** Verify that the JSON sent is correctly formatted and that all necessary information is included.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
