# Rotate approval link

Content Enrichment API / Approval Links

`POST https://api.ygo.ai/v2/project/content/rotateApprovalLink`

Replace one hotel's link token. The old token stops resolving immediately, so this is how a leaked or mis-sent link is invalidated. Everything else survives: the approval status, the approval timestamps and approver, the feedback history and the hotel's identified contacts, whose secrets keep working on the new token. Send the new link to the hotel afterwards — the old one is dead. A link that was revoked cannot be rotated back to life: it answers 404 `Approval link not found`, and `createApprovalLinks` is the way to mint a fresh one.

Exact spec (OpenAPI 3.0, JSON): https://docs.ygo.ai/reference/rotateApprovalLink.json

## Example request

```bash
curl -X POST 'https://api.ygo.ai/v2/project/content/rotateApprovalLink' \
  -H "Authorization: Bearer $YGO_API_KEY" \
  -H "X-Project-ID: $YGO_PROJECT_ID" \
  -H "Content-Type: application/json" \
  -d '{
  "HotelID": "019d9c2e-0ef8-7458-b0fa-8bed7182eb30"
}'
```

## Authorization

`Authorization: Bearer <key>`

Project-scoped API key

## Headers

- `X-Project-ID` (string (uuid), **required**)

  Project UUID. Required for all project-scoped endpoints.

  Example: `$YGO_PROJECT_ID`

## Request body

Required.

### application/json

Schema: object, `RotateApprovalLinkRequest`

The hotel whose link token should be replaced.

- `HotelID` (string (uuid), **required**)

  UUID of the hotel. Required, a valid non-nil UUID, and a live member of the calling project.

  Example: `019d9c2e-0ef8-7458-b0fa-8bed7182eb30`

#### Example request: rotate. Rotate one hotel's link

```json
{
  "HotelID": "019d9c2e-0ef8-7458-b0fa-8bed7182eb30"
}
```

## Responses

### 200 OK

The link with its new token. The previous token no longer resolves.

Headers:

- `X-Trace-ID` (string)

  Request trace ID for debugging (OpenTelemetry). Include this ID when contacting support about specific requests.

  Example: `abc123def456ghi789`

#### application/json

Schema: object, `RotateApprovalLinkResponse`

Single-object response envelope wrapping the rotated link.

- `Data` (object, `ApprovalLink`, **required**)

  One hotel's approval link and its state. The same shape is returned by createApprovalLinks and rotateApprovalLink; revokeApprovalLink returns it without `Token` (the link is dead), and `listApprovals` returns it minus `Token`, which that endpoint deliberately omits (contract A10.1).

  - `HotelID` (string (uuid), **required**)

    UUID of the hotel this link belongs to.

    Example: `019d9c2e-0ef8-7458-b0fa-8bed7182eb30`
  - `HotelName` (string, **required**)

    Display name of the hotel.

    Example: `Sotavento Beach Club`
  - `GiataID` (integer)

    The hotel's GIATA id. Omitted when the hotel has none.

    Example: `5721`
  - `MasterCode` (string)

    The calling project's master code for this hotel. Omitted when the project has no code for it.

    Example: `FUED0009`
  - `Token` (string, **required**)

    The 43-character link token — the full credential of the hotel's approval page. Build the link from it; do not log or display it.

    Example: `xPBOjXHomqBvKZ0nQ2sT7yWlR4dGuAeIcNvXbF9pMk3`

    Limits: min length 43, max length 43
  - `TokenPreview` (string, **required**)

    Display form of the token: its first 8 characters followed by an ellipsis. Never enough to reconstruct the link.

    Example: `xPBOjXHo...`
  - `Status` (string, **required**)

    Approval state of this hotel's link. `waiting_for_hotel` on creation; any feedback moves it to `feedback_received`; `feedback_applied` is set once the feedback has been worked in; `approved` is never left by a later feedback submission; the one way back to `waiting_for_hotel` is a re-minted link (createApprovalLinks after a revoke), which keeps ApprovedAt, ApprovedTextGeneratedAt and ApprovedBy as the record of the earlier approval.

    Values: `waiting_for_hotel`, `feedback_received`, `feedback_applied`, `approved`

    Example: `waiting_for_hotel`
  - `ApprovedAt` (string (date-time))

    When the hotel approved (RFC3339). Present once the hotel has ever approved: it is the RECORD of that approval and survives a later revoke and a re-minted link, so it can accompany a `waiting_for_hotel` Status (see createApprovalLinks). Only a fresh approval replaces it.

    Example: `2026-08-25T18:19:18.860882Z`
  - `ApprovedTextGeneratedAt` (string (date-time))

    Newest generation timestamp across the texts that were approved (RFC3339). Compare it with the hotel's current texts to see whether they changed since the approval. Present once the hotel has ever approved (it survives a revoke and a re-minted link, like ApprovedAt), and omitted then if none of the approved texts carried a timestamp.

    Example: `2026-08-19T14:14:57.674681Z`
  - `ApprovedBy` (object, `ApprovalApprover`)

    Present once the hotel has ever approved: the record of who signed off, kept across a later revoke and a re-minted link (so it can accompany a `waiting_for_hotel` Status) and replaced only by a fresh approval. The identity is the snapshot taken at approval time and survives deletion of the contact record (`approved_by` is `ON DELETE SET NULL`; the snapshot columns are not cleared).

    - `Name` (string, **required**)

      The contact's name.

      Example: `Ayşe Yılmaz`
    - `Email` (string (email))

      The contact's email address.

      Example: `ayse@sotavento.example`
    - `Phone` (string)

      The contact's phone number. Omitted when the contact did not supply one.

      Example: `+34 928 000 000`
  - `LastOpenedAt` (string (date-time))

    When the approval page was last loaded (RFC3339). Omitted while the link has never been opened.

    Example: `2026-08-25T18:19:18.966928Z`
  - `RevokedAt` (string (date-time))

    When the link was revoked (RFC3339). Omitted while the link is live. A link carrying it is never returned with a `Token`.

    Example: `2026-08-25T18:19:19.602402Z`
  - `Created` (boolean, **required**)

    `true` only when this call minted the credential in `Token`: a brand-new link, or a fresh one for a hotel whose link had been revoked. `false` for a hotel that already had a live link, and always `false` on rotateApprovalLink, revokeApprovalLink and listApprovals.

    Example: `true`
  - `CreatedBy` (string)

    Audit identity of who minted the link: a user token records the user's email; a project API key records its project-scoped identity (`project:<project-uuid>`). That is what is STORED; what is RETURNED is gated. The stored identity is an operator identity by construction, so in practice it carries an internal staff email — a contact route, and therefore contact PII on the same footing as `ApprovedBy.Email` and `ApprovedBy.Phone`: it is returned only to a caller presenting a user_ token, and is omitted entirely for a proj_ project token (the key is absent, not an empty string).

    Example: `editor@example.com`
  - `CreatedAt` (string (date-time), **required**)

    When the link was minted (RFC3339).

    Example: `2026-08-25T18:19:17.522006Z`
  - `UpdatedAt` (string (date-time), **required**)

    When the link row was last touched (RFC3339). The `updated_at` trigger fires on every update, so this moves on a status transition, an approval and a token rotation — and also when the hotel merely opens the page, because that stamps `last_opened_at`. Do not use it to detect approval-state changes.

    Example: `2026-08-25T18:19:17.522006Z`

##### Example: rotate. Rotated link of an already approved hotel

```json
{
  "Data": {
    "HotelID": "019d9c2e-0ef8-7458-b0fa-8bed7182eb30",
    "HotelName": "Sotavento Beach Club",
    "GiataID": 5721,
    "MasterCode": "FUED0009",
    "Token": "cP7tpTJPwR9mLxYaKu2NsE4vZbQdHfGjT1oIcXn6yA0",
    "TokenPreview": "cP7tpTJP...",
    "Status": "approved",
    "ApprovedAt": "2026-08-25T18:19:18.860882Z",
    "ApprovedTextGeneratedAt": "2026-08-19T14:14:57.674681Z",
    "ApprovedBy": {
      "Name": "Ayşe Yılmaz",
      "Email": "ayse@sotavento.example",
      "Phone": "+34 928 000 000"
    },
    "LastOpenedAt": "2026-08-25T18:19:18.966928Z",
    "Created": false,
    "CreatedBy": "editor@example.com",
    "CreatedAt": "2026-08-25T18:19:17.522006Z",
    "UpdatedAt": "2026-08-25T18:19:18.860882Z"
  }
}
```

##### Example: projectTokenCaller. Same call with a proj_ project token — contact PII omitted: ApprovedBy carries Name only and CreatedBy is absent

Identical request, answered for a caller presenting a `proj_` project token instead of a `user_` token. `ApprovedBy.Email`, `ApprovedBy.Phone` and `CreatedBy` are contact PII and are omitted entirely (the keys are absent, not empty strings). Everything else is unchanged.

```json
{
  "Data": {
    "HotelID": "019d9c2e-0ef8-7458-b0fa-8bed7182eb30",
    "HotelName": "Sotavento Beach Club",
    "GiataID": 5721,
    "MasterCode": "FUED0009",
    "Token": "cP7tpTJPwR9mLxYaKu2NsE4vZbQdHfGjT1oIcXn6yA0",
    "TokenPreview": "cP7tpTJP...",
    "Status": "approved",
    "ApprovedAt": "2026-08-25T18:19:18.860882Z",
    "ApprovedTextGeneratedAt": "2026-08-19T14:14:57.674681Z",
    "ApprovedBy": {
      "Name": "Ayşe Yılmaz"
    },
    "LastOpenedAt": "2026-08-25T18:19:18.966928Z",
    "Created": false,
    "CreatedAt": "2026-08-25T18:19:17.522006Z",
    "UpdatedAt": "2026-08-25T18:19:18.860882Z"
  }
}
```

### 400 Bad Request

Bad Request - the request body or the X-Project-ID header failed validation.

Headers:

- `X-Trace-ID` (string)

  Request trace ID for debugging (OpenTelemetry). Include this ID when contacting support about specific requests.

  Example: `abc123def456ghi789`

#### application/json

Schema: object, `ErrorResponse`

Standard v2 error response wrapper.

- `Error` (object, `ErrorDetail`, **required**)

  Error detail containing a machine-readable code and human-readable message.

  - `Code` (string, **required**)

    Machine-readable error code for programmatic handling.

    Example: `VALIDATION_ERROR`
  - `Message` (string, **required**)

    Human-readable error message.

    Example: `Validation failed`
  - `Fields` (array of object, `FieldError`)

    Field-level validation errors. Only present for VALIDATION_ERROR responses.

    Each item: A single field-level validation error.

    - `Field` (string, **required**)

      Path of the field that failed validation, as the request sends it: a dotted path for a field inside a nested request object, a bare name for a top-level one.

      Example: `Name`
    - `Message` (string, **required**)

      Human-readable validation error message for this field.

      Example: `Name is required`
    - `Code` (string)

      Machine-readable reason the field failed validation. Optional; clients should fall back to Message when it is absent or unrecognized.

      Values: `REQUIRED`, `TOO_LONG`, `TOO_SHORT`, `OUT_OF_RANGE`, `TOO_MANY`, `INVALID_FORMAT`, `NOT_ALLOWED`, `CONFLICT`, `INVALID_ENCODING`, `INSECURE_SCHEME`, `UNSAFE_CONTENT`, `REQUIRED_WHEN_ENABLED`

      Example: `TOO_LONG`
    - `Params` (map of string to any)

      Machine-readable values the message is built from, such as limits or allowed values. Keys are PascalCase; which keys are present depends on Code. Optional.

      Example:

      ```json
      {
        "Max": 200
      }
      ```

##### Example: missingProjectHeader. X-Project-ID header missing

```json
{
  "Error": {
    "Code": "VALIDATION_ERROR",
    "Message": "X-Project-ID header is required"
  }
}
```

##### Example: invalidBody. Malformed request body

```json
{
  "Error": {
    "Code": "VALIDATION_ERROR",
    "Message": "Invalid request body"
  }
}
```

##### Example: invalidHotelID. HotelID missing or not a valid UUID

```json
{
  "Error": {
    "Code": "VALIDATION_ERROR",
    "Message": "Validation failed",
    "Fields": [
      {
        "Field": "HotelID",
        "Message": "HotelID must be a valid UUID"
      }
    ]
  }
}
```

### 401 Unauthorized

Unauthorized - Invalid or missing bearer token.

Headers:

- `X-Trace-ID` (string)

  Request trace ID for debugging (OpenTelemetry). Include this ID when contacting support about specific requests.

  Example: `abc123def456ghi789`

#### application/json

Schema: object, `ErrorResponse`

Standard v2 error response wrapper.

- `Error` (object, `ErrorDetail`, **required**)

  Error detail containing a machine-readable code and human-readable message.

  - `Code` (string, **required**)

    Machine-readable error code for programmatic handling.

    Example: `VALIDATION_ERROR`
  - `Message` (string, **required**)

    Human-readable error message.

    Example: `Validation failed`
  - `Fields` (array of object, `FieldError`)

    Field-level validation errors. Only present for VALIDATION_ERROR responses.

    Each item: A single field-level validation error.

    - `Field` (string, **required**)

      Path of the field that failed validation, as the request sends it: a dotted path for a field inside a nested request object, a bare name for a top-level one.

      Example: `Name`
    - `Message` (string, **required**)

      Human-readable validation error message for this field.

      Example: `Name is required`
    - `Code` (string)

      Machine-readable reason the field failed validation. Optional; clients should fall back to Message when it is absent or unrecognized.

      Values: `REQUIRED`, `TOO_LONG`, `TOO_SHORT`, `OUT_OF_RANGE`, `TOO_MANY`, `INVALID_FORMAT`, `NOT_ALLOWED`, `CONFLICT`, `INVALID_ENCODING`, `INSECURE_SCHEME`, `UNSAFE_CONTENT`, `REQUIRED_WHEN_ENABLED`

      Example: `TOO_LONG`
    - `Params` (map of string to any)

      Machine-readable values the message is built from, such as limits or allowed values. Keys are PascalCase; which keys are present depends on Code. Optional.

      Example:

      ```json
      {
        "Max": 200
      }
      ```

##### Example: missingToken. No Authorization header

```json
{
  "Error": {
    "Code": "UNAUTHORIZED",
    "Message": "Missing bearer token"
  }
}
```

##### Example: invalidToken. The bearer token is not valid

```json
{
  "Error": {
    "Code": "UNAUTHORIZED",
    "Message": "Invalid bearer token"
  }
}
```

### 403 Forbidden

Forbidden - the caller is authenticated but may not act on this project. Also returned with code INSUFFICIENT_SCOPE when the API key does not carry the content.authoring:write permission this endpoint requires.

Headers:

- `X-Trace-ID` (string)

  Request trace ID for debugging (OpenTelemetry). Include this ID when contacting support about specific requests.

  Example: `abc123def456ghi789`

#### application/json

Schema: object, `ErrorResponse`

Standard v2 error response wrapper.

- `Error` (object, `ErrorDetail`, **required**)

  Error detail containing a machine-readable code and human-readable message.

  - `Code` (string, **required**)

    Machine-readable error code for programmatic handling.

    Example: `VALIDATION_ERROR`
  - `Message` (string, **required**)

    Human-readable error message.

    Example: `Validation failed`
  - `Fields` (array of object, `FieldError`)

    Field-level validation errors. Only present for VALIDATION_ERROR responses.

    Each item: A single field-level validation error.

    - `Field` (string, **required**)

      Path of the field that failed validation, as the request sends it: a dotted path for a field inside a nested request object, a bare name for a top-level one.

      Example: `Name`
    - `Message` (string, **required**)

      Human-readable validation error message for this field.

      Example: `Name is required`
    - `Code` (string)

      Machine-readable reason the field failed validation. Optional; clients should fall back to Message when it is absent or unrecognized.

      Values: `REQUIRED`, `TOO_LONG`, `TOO_SHORT`, `OUT_OF_RANGE`, `TOO_MANY`, `INVALID_FORMAT`, `NOT_ALLOWED`, `CONFLICT`, `INVALID_ENCODING`, `INSECURE_SCHEME`, `UNSAFE_CONTENT`, `REQUIRED_WHEN_ENABLED`

      Example: `TOO_LONG`
    - `Params` (map of string to any)

      Machine-readable values the message is built from, such as limits or allowed values. Keys are PascalCase; which keys are present depends on Code. Optional.

      Example:

      ```json
      {
        "Max": 200
      }
      ```

##### Example: insufficientScope. Missing required scope

```json
{
  "Error": {
    "Code": "INSUFFICIENT_SCOPE",
    "Message": "token lacks scope content.authoring:write"
  }
}
```

##### Example: accessDenied. The user token has no editor access to the project

```json
{
  "Error": {
    "Code": "FORBIDDEN",
    "Message": "Access denied to project"
  }
}
```

##### Example: noProjectScope. The request carries no project scope

```json
{
  "Error": {
    "Code": "FORBIDDEN",
    "Message": "Project access required"
  }
}
```

### 404 Not Found

Not Found - the project or the hotel is not reachable for this caller.

Headers:

- `X-Trace-ID` (string)

  Request trace ID for debugging (OpenTelemetry). Include this ID when contacting support about specific requests.

  Example: `abc123def456ghi789`

#### application/json

Schema: object, `ErrorResponse`

Standard v2 error response wrapper.

- `Error` (object, `ErrorDetail`, **required**)

  Error detail containing a machine-readable code and human-readable message.

  - `Code` (string, **required**)

    Machine-readable error code for programmatic handling.

    Example: `VALIDATION_ERROR`
  - `Message` (string, **required**)

    Human-readable error message.

    Example: `Validation failed`
  - `Fields` (array of object, `FieldError`)

    Field-level validation errors. Only present for VALIDATION_ERROR responses.

    Each item: A single field-level validation error.

    - `Field` (string, **required**)

      Path of the field that failed validation, as the request sends it: a dotted path for a field inside a nested request object, a bare name for a top-level one.

      Example: `Name`
    - `Message` (string, **required**)

      Human-readable validation error message for this field.

      Example: `Name is required`
    - `Code` (string)

      Machine-readable reason the field failed validation. Optional; clients should fall back to Message when it is absent or unrecognized.

      Values: `REQUIRED`, `TOO_LONG`, `TOO_SHORT`, `OUT_OF_RANGE`, `TOO_MANY`, `INVALID_FORMAT`, `NOT_ALLOWED`, `CONFLICT`, `INVALID_ENCODING`, `INSECURE_SCHEME`, `UNSAFE_CONTENT`, `REQUIRED_WHEN_ENABLED`

      Example: `TOO_LONG`
    - `Params` (map of string to any)

      Machine-readable values the message is built from, such as limits or allowed values. Keys are PascalCase; which keys are present depends on Code. Optional.

      Example:

      ```json
      {
        "Max": 200
      }
      ```

##### Example: projectNotFound. The project does not exist or was deleted (user tokens)

```json
{
  "Error": {
    "Code": "NOT_FOUND",
    "Message": "Project not found"
  }
}
```

##### Example: hotelNotFound. The hotel is not a live member of the project

```json
{
  "Error": {
    "Code": "NOT_FOUND",
    "Message": "Hotel not found"
  }
}
```

##### Example: linkNotFound. The hotel is a member but has no live link — never minted, or revoked

```json
{
  "Error": {
    "Code": "NOT_FOUND",
    "Message": "Approval link not found"
  }
}
```

### 429 Too Many Requests

Too Many Requests. The response includes a `Retry-After` header with the number of seconds to wait before retrying.

Headers:

- `X-Trace-ID` (string)

  Request trace ID for debugging (OpenTelemetry). Include this ID when contacting support about specific requests.

  Example: `abc123def456ghi789`
- `Retry-After` (integer)

  Number of seconds to wait before retrying the request. Present on 429 responses.

  Example: `39`

  Limits: min 1

#### application/json

Schema: object, `ErrorResponse`

Standard v2 error response wrapper.

- `Error` (object, `ErrorDetail`, **required**)

  Error detail containing a machine-readable code and human-readable message.

  - `Code` (string, **required**)

    Machine-readable error code for programmatic handling.

    Example: `VALIDATION_ERROR`
  - `Message` (string, **required**)

    Human-readable error message.

    Example: `Validation failed`
  - `Fields` (array of object, `FieldError`)

    Field-level validation errors. Only present for VALIDATION_ERROR responses.

    Each item: A single field-level validation error.

    - `Field` (string, **required**)

      Path of the field that failed validation, as the request sends it: a dotted path for a field inside a nested request object, a bare name for a top-level one.

      Example: `Name`
    - `Message` (string, **required**)

      Human-readable validation error message for this field.

      Example: `Name is required`
    - `Code` (string)

      Machine-readable reason the field failed validation. Optional; clients should fall back to Message when it is absent or unrecognized.

      Values: `REQUIRED`, `TOO_LONG`, `TOO_SHORT`, `OUT_OF_RANGE`, `TOO_MANY`, `INVALID_FORMAT`, `NOT_ALLOWED`, `CONFLICT`, `INVALID_ENCODING`, `INSECURE_SCHEME`, `UNSAFE_CONTENT`, `REQUIRED_WHEN_ENABLED`

      Example: `TOO_LONG`
    - `Params` (map of string to any)

      Machine-readable values the message is built from, such as limits or allowed values. Keys are PascalCase; which keys are present depends on Code. Optional.

      Example:

      ```json
      {
        "Max": 200
      }
      ```

##### Example: rateLimited. Limit exceeded

```json
{
  "Error": {
    "Code": "RATE_LIMIT_EXCEEDED",
    "Message": "Rate limit exceeded. Retry after the number of seconds in the Retry-After header."
  }
}
```

### 500 Internal Server Error

Internal Server Error - Unexpected server error. Include the X-Trace-ID header value when contacting support.

Headers:

- `X-Trace-ID` (string)

  Request trace ID for debugging (OpenTelemetry). Include this ID when contacting support about specific requests.

  Example: `abc123def456ghi789`

#### application/json

Schema: object, `ErrorResponse`

Standard v2 error response wrapper.

- `Error` (object, `ErrorDetail`, **required**)

  Error detail containing a machine-readable code and human-readable message.

  - `Code` (string, **required**)

    Machine-readable error code for programmatic handling.

    Example: `VALIDATION_ERROR`
  - `Message` (string, **required**)

    Human-readable error message.

    Example: `Validation failed`
  - `Fields` (array of object, `FieldError`)

    Field-level validation errors. Only present for VALIDATION_ERROR responses.

    Each item: A single field-level validation error.

    - `Field` (string, **required**)

      Path of the field that failed validation, as the request sends it: a dotted path for a field inside a nested request object, a bare name for a top-level one.

      Example: `Name`
    - `Message` (string, **required**)

      Human-readable validation error message for this field.

      Example: `Name is required`
    - `Code` (string)

      Machine-readable reason the field failed validation. Optional; clients should fall back to Message when it is absent or unrecognized.

      Values: `REQUIRED`, `TOO_LONG`, `TOO_SHORT`, `OUT_OF_RANGE`, `TOO_MANY`, `INVALID_FORMAT`, `NOT_ALLOWED`, `CONFLICT`, `INVALID_ENCODING`, `INSECURE_SCHEME`, `UNSAFE_CONTENT`, `REQUIRED_WHEN_ENABLED`

      Example: `TOO_LONG`
    - `Params` (map of string to any)

      Machine-readable values the message is built from, such as limits or allowed values. Keys are PascalCase; which keys are present depends on Code. Optional.

      Example:

      ```json
      {
        "Max": 200
      }
      ```

##### Example: rotateFailed. The token could not be replaced

```json
{
  "Error": {
    "Code": "INTERNAL_ERROR",
    "Message": "Failed to rotate approval link"
  }
}
```

##### Example: membershipFailed. Hotel membership could not be verified

```json
{
  "Error": {
    "Code": "INTERNAL_ERROR",
    "Message": "Failed to verify hotel"
  }
}
```
