# Register a vehicle

Source: https://amanucci.com/fr/docs/developers/api/settings/appendVehicle

## POST /v1/entities/{entityId}/vehicles/{plate}

Register a vehicle

Register a vehicle, or append its next version. The organisation's owner or a firm accountant holding `ledger.manage` (a member or a staffer meets 403 `authority-required`). `expectedSeq` is the pinned-row idempotency key: identical retry 200, stale head 409. The database judges the row (422 `vehicle_invalid`, each refusal by name): the plate, the vocabularies, an exclusion matching its category, a zero-emission fuel at 0 g, the dates' order, private fuel only with a holder.

Operation ID: `appendVehicle`

### Parameters

```json
[
  {
    "schema": {
      "type": "string",
      "format": "uuid"
    },
    "required": true,
    "name": "entityId",
    "in": "path"
  },
  {
    "schema": {
      "type": "string",
      "minLength": 2,
      "maxLength": 20,
      "description": "The plate, as printed: separators and case are ignored (`1-abc-234` is `1ABC234`)."
    },
    "required": true,
    "description": "The plate, as printed: separators and case are ignored (`1-abc-234` is `1ABC234`).",
    "name": "plate",
    "in": "path"
  }
]
```

### Request body

```json
{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/AppendVehicle"
      }
    }
  }
}
```

### Responses

#### 200 Duplicate-ok: this exact version was already the head.

```json
{
  "application/json": {
    "schema": {
      "$ref": "#/components/schemas/VehicleResult"
    }
  }
}
```

#### 201 The new head.

```json
{
  "application/json": {
    "schema": {
      "$ref": "#/components/schemas/VehicleResult"
    }
  }
}
```

#### 401 Dead or absent credential (`unauthenticated`).

```json
{
  "application/problem+json": {
    "schema": {
      "$ref": "#/components/schemas/Problem"
    }
  }
}
```

#### 403 Authenticated, present, and refused: a missing grant, a missing seat, or a missing step-up.

```json
{
  "application/problem+json": {
    "schema": {
      "$ref": "#/components/schemas/Problem"
    }
  }
}
```

#### 404 Absent, or hidden from this asker — the two are indistinguishable (`not-found`).

```json
{
  "application/problem+json": {
    "schema": {
      "$ref": "#/components/schemas/Problem"
    }
  }
}
```

#### 409 The world is not in the state the request assumed: a stale `expectedSeq`, or a transition already made.

```json
{
  "application/problem+json": {
    "schema": {
      "$ref": "#/components/schemas/Problem"
    }
  }
}
```

#### 422 The request did not satisfy the schema (`invalid-input`).

```json
{
  "application/problem+json": {
    "schema": {
      "$ref": "#/components/schemas/Problem"
    }
  }
}
```

#### 429 Too many requests on this door's bucket (`rate-limited`); refused before any handler ran, `Retry-After` says when to come back.

```json
{
  "application/problem+json": {
    "schema": {
      "$ref": "#/components/schemas/Problem"
    }
  }
}
```

#### 503 Temporarily unavailable; `Retry-After` says when to come back.

```json
{
  "application/problem+json": {
    "schema": {
      "$ref": "#/components/schemas/Problem"
    }
  }
}
```
