> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lexio.rent/llms.txt
> Use this file to discover all available pages before exploring further.

# Cycle de vie d’une location

## Statuts

| `status` | Libellé | Sens |
| - | - | - |
| `RESERVED` | Réservée | Réservation confirmée, véhicule pas encore remis. État initial d’une location créée par l’API. |
| `PENDING_APPROVAL` | En attente d’approbation | Demande reçue par le site de réservation du loueur, paiement autorisé mais non encaissé, en attente de l’approbation du loueur. Jamais créée par l’API ; une clé partenaire ne la voit pas. |
| `IN_PROGRESS` | En cours | Véhicule remis au client (départ fait). |
| `COMPLETED` | Terminée | Véhicule rendu (retour fait). État final. |
| `CANCELLED` | Annulée | Location annulée, ou demande refusée ou expirée. État final. |

Transitions :

* `RESERVED` → `IN_PROGRESS` : départ (`pickup`).
* `IN_PROGRESS` → `COMPLETED` : retour (`return`).
* `RESERVED` → `CANCELLED` : annulation (`cancel`).
* `PENDING_APPROVAL` → `RESERVED` : approbation, dans Lexio seulement.
* `PENDING_APPROVAL` → `CANCELLED` : refus (`cancel`) ou expiration.

Une location créée par l’API naît `RESERVED`. Le loueur fait les mêmes transitions dans Lexio. Une location `IN_PROGRESS` ou `COMPLETED` ne s’annule plus. Chaque changement de statut produit un événement (`rental.updated`, ou `rental.cancelled` pour une annulation) : voir [Synchronisation par événements](https://docs.lexio.rent/synchronisation.md).

## Actions possibles selon le statut

Une action hors de ses statuts répond `409 RENTAL_STATUS_NOT_ALLOWED`, avec `rentalStatus`, `allowedStatuses` et `action` (première colonne). « sans `champ` » signale un champ refusé dans ce statut : le reste de l’action passe.

| `action` | Opération | Statuts permis |
| - | - | - |
| `CANCEL` | [`POST /rentals/{rentalId}/cancel`](https://docs.lexio.rent/api-reference/locations/cancel-rental) | `RESERVED`, `PENDING_APPROVAL` |
| `PICKUP` | [`POST /rentals/{rentalId}/pickup`](https://docs.lexio.rent/api-reference/depart-et-retour/pick-up-rental) | `RESERVED` |
| `RETURN` | [`POST /rentals/{rentalId}/return`](https://docs.lexio.rent/api-reference/depart-et-retour/return-rental) | `IN_PROGRESS` |
| `RESCHEDULE` | [`POST /rentals/{rentalId}/reschedule`](https://docs.lexio.rent/api-reference/modifications/reschedule-rental) | `RESERVED`, `IN_PROGRESS` (sans `startAt`) |
| `CHANGE_VEHICLE` | [`POST /rentals/{rentalId}/change-vehicle`](https://docs.lexio.rent/api-reference/modifications/change-rental-vehicle) | `RESERVED` (sans `odometers`), `IN_PROGRESS` |
| `CHANGE_COVERAGE` | [`POST /rentals/{rentalId}/change-coverage`](https://docs.lexio.rent/api-reference/modifications/change-rental-coverage) | `RESERVED`, `IN_PROGRESS` |
| `CHANGE_CUSTOMER` | [`POST /rentals/{rentalId}/change-customer`](https://docs.lexio.rent/api-reference/modifications/change-rental-customer) | `RESERVED` |
| `SET_OPTION_QUANTITY` | [`PUT /rentals/{rentalId}/options/{optionId}`](https://docs.lexio.rent/api-reference/modifications/set-rental-option-quantity) | `RESERVED`, `IN_PROGRESS` |
| `REMOVE_OPTION` | [`DELETE /rentals/{rentalId}/options/{optionId}`](https://docs.lexio.rent/api-reference/modifications/remove-rental-option) | `RESERVED`, `IN_PROGRESS` |
| `EDIT_NOTES` | [`PATCH /rentals/{rentalId}`](https://docs.lexio.rent/api-reference/locations/update-rental) (`notes`) | `RESERVED`, `PENDING_APPROVAL`, `IN_PROGRESS`, `COMPLETED`, `CANCELLED` |
| `EDIT_LOCATIONS` | [`PATCH /rentals/{rentalId}`](https://docs.lexio.rent/api-reference/locations/update-rental) (`pickupLocation`, `returnLocation`) | `RESERVED`, `PENDING_APPROVAL`, `IN_PROGRESS` (sans `pickupLocation`) |
| `DELETE` | [`DELETE /rentals/{rentalId}`](https://docs.lexio.rent/api-reference/locations/delete-rental) | `RESERVED`, `CANCELLED` |
| `ADD_PAYMENT` | [`POST /rentals/{rentalId}/payments`](https://docs.lexio.rent/api-reference/paiements/create-rental-payment) (`PAYMENT`, `DEPOSIT`) | `RESERVED`, `IN_PROGRESS`, `COMPLETED` |
| `REFUND` | [`POST /rentals/{rentalId}/payments`](https://docs.lexio.rent/api-reference/paiements/create-rental-payment) (`REFUND`) | `RESERVED`, `IN_PROGRESS`, `COMPLETED`, `CANCELLED` |
| `DELETE_PAYMENT` | [`DELETE /rentals/{rentalId}/payments/{paymentId}`](https://docs.lexio.rent/api-reference/paiements/delete-rental-payment) | `RESERVED`, `IN_PROGRESS`, `COMPLETED` |
| `UPLOAD_PHOTO` | [`POST /rentals/{rentalId}/photo-uploads`](https://docs.lexio.rent/api-reference/depart-et-retour/create-rental-photo-uploads), [`POST /rentals/{rentalId}/photos`](https://docs.lexio.rent/api-reference/depart-et-retour/register-rental-photos) | `RESERVED` (phase `DEPARTURE` seule), `IN_PROGRESS`, `COMPLETED` |
| `DELETE_PHOTO` | [`DELETE /rentals/{rentalId}/photos/{photoId}`](https://docs.lexio.rent/api-reference/depart-et-retour/delete-rental-photo) | `RESERVED` (phase `DEPARTURE` seule), `IN_PROGRESS`, `COMPLETED` |

* Annuler une location déjà `CANCELLED` répond `200` sans rien écrire, avec `effects.cancellation.alreadyCancelled` à `true`.
* Annuler une demande `PENDING_APPROVAL` la refuse : Lexio tente ensuite de relâcher l’autorisation de paiement du client, et `effects.paymentAuthorizationRelease` en donne le résultat.
* `?dryRun=true` prévisualise les actions qui l’acceptent sans rien écrire : voir [Idempotence et reprise](https://docs.lexio.rent/idempotence.md).

## Caution

La caution se demande à la réservation (`deposit`) et s’encaisse à part, en paiement de type `DEPOSIT` ; elle n’entre ni dans `totalTTC` ni dans `balance`. **Sa restitution ou sa retenue ne se fait pas par l’API** : le loueur la décide dans Lexio après le retour. L’API la lit dans les lignes `DEPOSIT` de [`GET /rentals/{rentalId}/payments`](https://docs.lexio.rent/api-reference/paiements/list-rental-payments) et, à l’annulation, dans `effects.cancellation.depositsHeld` (caution encaissée à rendre, empreinte à relâcher).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.