# Guest Update

## Update a Guest

Use this endpoint to modify an existing guest's profile information. You can change **contact details**, **address**, **preferences**, and other guest information.\
Updates will validate the new information and check for conflicts.

#### Endpoint

```http
PATCH /api/v1/client/guests/{guestId}
```

#### Example `curl`

```bash
curl "/api/v1/client/guests/f1b2c3d4-5678-49ab-9cde-112233445566" \
  -X PATCH \
  -H "accept: application/json" \
  -H "content-type: application/json" \
  -H "origin: https://docs.hostelmate.co" \
  --data-raw '{
    "guest": {
      "phone": "+447712345678",
      "address": {
        "line1": "Westminster",
        "city": "London",
        "postal_code": "SW1A 1AA",
        "country_code": "GB"
      },
      "preferences": {
        "language": "en",
        "newsletter": false,
        "marketing": true
      }
    }
  }'
```

> This is a **partial** update. Send only the fields you want to change.

***

#### Request Payload

**Top-level Fields**

<table><thead><tr><th width="104.3515625">Field</th><th width="92.70703125">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>guest</code></td><td>object</td><td>Guest-level updates, such as contact details, address, and preferences.</td></tr></tbody></table>

**Guest Object (updatable)**

<table><thead><tr><th width="104.3515625">Field</th><th width="92.70703125">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>first_name</code></td><td>string</td><td>Update guest's first name.</td></tr><tr><td><code>last_name</code></td><td>string</td><td>Update guest's last name.</td></tr><tr><td><code>email</code></td><td>string</td><td>Update guest's email address. Must be a valid email format.</td></tr><tr><td><code>phone</code></td><td>string</td><td>Update guest's phone number. E.164 format recommended.</td></tr><tr><td><code>country_code</code></td><td>string</td><td>Update guest's country code. ISO 3166-1 alpha-2.</td></tr><tr><td><code>address</code></td><td>object</td><td>Update guest's postal address (see below).</td></tr><tr><td><code>date_of_birth</code></td><td>string</td><td>Update guest's date of birth (format: YYYY-MM-DD).</td></tr><tr><td><code>nationality</code></td><td>string</td><td>Update guest's nationality. ISO 3166-1 alpha-2.</td></tr><tr><td><code>preferences</code></td><td>object</td><td>Update guest preferences (see below).</td></tr></tbody></table>

**Address Object**

<table><thead><tr><th width="104.3515625">Field</th><th width="92.70703125">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>line1</code></td><td>string</td><td>Street line 1.</td></tr><tr><td><code>city</code></td><td>string</td><td>City.</td></tr><tr><td><code>postal_code</code></td><td>string</td><td>Postal/ZIP code.</td></tr><tr><td><code>country_code</code></td><td>string</td><td>ISO 3166-1 alpha-2 (e.g., <code>GB</code>).</td></tr></tbody></table>

**Preferences Object**

<table><thead><tr><th width="104.3515625">Field</th><th width="92.70703125">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>language</code></td><td>string</td><td>Preferred language code (e.g., <code>en</code>, <code>fr</code>).</td></tr><tr><td><code>newsletter</code></td><td>boolean</td><td>Whether guest wants to receive newsletters.</td></tr><tr><td><code>marketing</code></td><td>boolean</td><td>Whether guest consents to marketing communications.</td></tr></tbody></table>

***

#### Response (200 OK)

```json
{
  "guestId": "f1b2c3d4-5678-49ab-9cde-112233445566",
  "first_name": "John",
  "last_name": "Doe",
  "email": "john@example.com",
  "phone": "+447712345678",
  "country_code": "GB",
  "address": {
    "line1": "Westminster",
    "city": "London",
    "postal_code": "SW1A 1AA",
    "country_code": "GB"
  },
  "date_of_birth": "1990-05-15",
  "nationality": "GB",
  "preferences": {
    "language": "en",
    "newsletter": false,
    "marketing": true
  },
  "updatedAt": "2025-10-02T11:05:13Z"
}
```

***

#### Validation Rules

* The request may include any subset of fields; missing fields are left unchanged.
* If `email` is provided, it must be a valid email format and not conflict with existing guests.
* If `date_of_birth` is provided, it must be a valid date in YYYY-MM-DD format.
* If `country_code` or `nationality` are provided, they must be valid ISO 3166-1 alpha-2 codes.
* If `phone` is provided, it should follow E.164 format.

***

#### Error Codes

<table><thead><tr><th width="104.3515625">HTTP</th><th width="92.70703125">Code</th><th>Description</th></tr></thead><tbody><tr><td>400</td><td><code>bad_request</code></td><td>Invalid field(s) or payload structure.</td></tr><tr><td>404</td><td><code>guest_not_found</code></td><td>No guest with the specified <code>guestId</code>.</td></tr><tr><td>409</td><td><code>email_conflict</code></td><td>New email address already exists for another guest.</td></tr><tr><td>422</td><td><code>invalid_country_code</code></td><td>Invalid country code or nationality provided.</td></tr><tr><td>422</td><td><code>invalid_date_format</code></td><td>Invalid date format for <code>date_of_birth</code>.</td></tr><tr><td>500</td><td><code>server_error</code></td><td>Unexpected error.</td></tr></tbody></table>
