# Générer une url

Pour générer une url embed, vous devez faire un POST en passant bien votre clé d'API en `Bearer Token`.

Pensez aussi à bien ajouter votre ID tenant dans le header `X-Tenant`.

## Générer une url embed

<mark style="color:green;">`POST`</mark> `https://api.cards-microlearning.com/v1/embeds`

#### Headers

| Name                                       | Valeur                                   |
| ------------------------------------------ | ---------------------------------------- |
| Content-Type                               | `application/json`                       |
| Authorization                              | `Bearer <token API>`                     |
| X-Tenant<mark style="color:red;">\*</mark> | `‹Identifiant de votre espace (Tenant)>` |

#### Request Body

| Name                                    | Type    | Description                                                                          |
| --------------------------------------- | ------- | ------------------------------------------------------------------------------------ |
| type<mark style="color:red;">\*</mark>  | String  | <p>Type d'url à générer. Peut-être :<br>- training<br>- trainings</p>                |
| training\_id                            | Uuid    | L'ID de la formation a afficher (requis si le "type" est "training").                |
| email<mark style="color:red;">\*</mark> | Email   | L'adresse mail de l'apprenant pour qui afficher la ou les formations.                |
| once                                    | Boolean | Pour dire si l'url est à usage unique. (Default true)                                |
| expires\_at                             | Date    | <p>Date d'expiration de l'url embed.</p><p>Format : yyyy-mm-dd (ex : 2024-09-25)</p> |

{% tabs %}
{% tab title="200: OK Retourne une réponse en JSON contenant l'url." %}

```json
{
    "message": "Embed link created",
    "url": "https://embed.cards-microlearning.com/xxxxxxxxxx"
}
```

{% endtab %}

{% tab title="400: Bad Request Retourne les infos dans un JSON" %}
Exemples si un champ est mal renseigné :

```json
{
  "message": "The training id field is required when type is training.",
  "errors": {
    "training_id": [
      "The training id field is required when type is training."
    ]
  }
}
```

Exemple si l'apprenant n'existe pas :

```json
{
  "message": "User doesn't exist"
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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:

```
GET https://docapi.cards-microlearning.com/embeds/generer-une-url.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
