# Emote generation

In order to create an emote the following flow must happen:&#x20;

First, a user must have been created, follow the [user creation guide](user-creation) if it's not already done.

You will have to create a generation token with the following route.



{% openapi src="https://sdk-api.dev.kinetix.tech/swagger.json" path="/v1/process/token" method="post" %}
[https://sdk-api.dev.kinetix.tech/swagger.json](https://sdk-api.dev.kinetix.tech/swagger.json)
{% endopenapi %}

You can generate a QR code with the 'url' field in order to redirect to the PWA.\
The PWA will use the token and run the process on it's own.\
The token can only be used **once**, and has a **5 minutes TTL** in order to prevent abuse&#x73;**.**\
\
You have the ability to provide arbitrary metadata that will be attached to the process and then the emote. This could be used for example to implement customizable emotes with GTA's animation flags.\
\
As the server owner, you are responsible for the token generation. Generation processes will cost money and you have to design your system in a way that [ensure you can generate revenue](paywalls).

You can list the processes of a user with the following route :

{% openapi src="https://sdk-api.dev.kinetix.tech/swagger.json/" path="/v2/users/{userId}/processes" method="get" %}
[https://sdk-api.dev.kinetix.tech/swagger.json/](https://sdk-api.dev.kinetix.tech/swagger.json/)
{% endopenapi %}

The emote creation process will evolve through these different states :

<figure><img src="https://4274712517-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsSjjpyacKBTrm5tQ9SyL%2Fuploads%2FU7HIvFHVCVyQGmxy5qEd%2FStatuses.png?alt=media&#x26;token=0c9efe6d-f6fe-436a-b9b0-e640e9270b4e" alt=""><figcaption><p>Process statuses</p></figcaption></figure>

* **Pending**: When the process is queued to be processed by our GPU cluster
* **Processing**: When the ML algorithm is running on the video
* **Done**: When the inference was successful
* **Failed**:
  * An unknown error happens when the algorithm failed due to an unhandled error
  * A known error code will be returned if the video input is not processable
    * Too many people
    * No human detected on screen
    * The detected actor is too small
* **Validated & Rejected:** Optional user validation step that is [detailed here](retake-process).

When the YCD File generation setting is enabled, an extra status called 'gta\_done' will be present in the [webhook](webhook).

You are also able to filter the processes by their creation date, allowing you for example to only display the processes recently created.



In order to fetch the content of a successful process, you need to call the emote route with the 'emote' uuid of the process object:

{% openapi src="https://sdk-api.dev.kinetix.tech/swagger.json/" path="/v1/emotes/{uuid}" method="get" %}
[https://sdk-api.dev.kinetix.tech/swagger.json/](https://sdk-api.dev.kinetix.tech/swagger.json/)
{% endopenapi %}

With this route you are able to get the asset's metadata and all the associated files, including the YCD file through a signed download link.

In our FiveM implementation, we download the output file and let the Cfx Server handle the Client - Server streaming. This way, even if the API was down, you would still be able to play existing emotes in game.
