{
  "openapi": "3.0.0",
  "info": {
    "title": "YGO API: Add tag to hotels (bulk)",
    "version": "2.0.0"
  },
  "servers": [
    {
      "url": "https://api.ygo.ai",
      "description": "Production and Sandbox (determined by API key)"
    }
  ],
  "paths": {
    "/v2/project/content/addTagToHotels": {
      "post": {
        "summary": "Add tag to hotels (bulk)",
        "description": "Add a project tag to up to 1000 hotels at once. Tag ownership is checked once (404 if foreign). Each hotel id passes the project-membership escalation guard: a live member is 'applied', a non-member is 'skipped_not_member' (never tagged), a malformed id is 'invalid'. Returns the per-hotel outcomes.",
        "operationId": "addTagToHotels",
        "tags": [
          "Content Enrichment API/Tags"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/X-Project-ID"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddTagToHotelsRequest"
              },
              "examples": {
                "bulk": {
                  "summary": "Apply a tag to several hotels",
                  "value": {
                    "TagID": "0192fc01-1111-7abc-8def-aaaaaaaaaaaa",
                    "HotelIDs": [
                      "0192fb17-5dc6-7abc-8def-123456789abc",
                      "0192fb18-6ed7-7abc-8def-223456789abc"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Bulk add processed. Each hotel id carries its own outcome.",
            "headers": {
              "X-Trace-ID": {
                "$ref": "#/components/headers/X-Trace-ID"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AddTagToHotelsResponse"
                },
                "examples": {
                  "bulk": {
                    "summary": "A mixed batch: one applied, one skipped, one invalid",
                    "value": {
                      "Data": {
                        "TagID": "0192fc01-1111-7abc-8def-aaaaaaaaaaaa",
                        "Results": [
                          {
                            "HotelID": "0192fb17-5dc6-7abc-8def-123456789abc",
                            "Status": "applied"
                          },
                          {
                            "HotelID": "0192fb18-6ed7-7abc-8def-223456789abc",
                            "Status": "skipped_not_member"
                          },
                          {
                            "HotelID": "not-a-uuid",
                            "Status": "invalid"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AddTagToHotelsRequest": {
        "type": "object",
        "required": [
          "TagID",
          "HotelIDs"
        ],
        "description": "Request body for bulk-adding a tag to hotels.",
        "properties": {
          "TagID": {
            "type": "string",
            "format": "uuid",
            "description": "UUID of the project tag to apply. Must be a valid, non-nil UUID belonging to the calling project; a foreign tag returns 404.",
            "example": "0192fc01-1111-7abc-8def-aaaaaaaaaaaa"
          },
          "HotelIDs": {
            "type": "array",
            "minItems": 1,
            "maxItems": 1000,
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Hotel UUIDs to tag. Must contain between 1 and 1000 ids. Each id is validated and membership-checked individually; a malformed id is reported 'invalid' in the per-hotel results rather than failing the whole request.",
            "example": [
              "0192fb17-5dc6-7abc-8def-123456789abc",
              "0192fb18-6ed7-7abc-8def-223456789abc"
            ]
          }
        }
      },
      "AddTagToHotelsResponse": {
        "type": "object",
        "required": [
          "Data"
        ],
        "description": "Single-object response envelope wrapping the bulk add outcome.",
        "properties": {
          "Data": {
            "$ref": "#/components/schemas/BulkTagResult"
          }
        }
      },
      "BulkTagHotelResult": {
        "type": "object",
        "required": [
          "HotelID",
          "Status"
        ],
        "description": "The outcome for one hotel in a bulk add.",
        "properties": {
          "HotelID": {
            "type": "string",
            "description": "The hotel id from the request (echoed verbatim, so an invalid id appears as submitted).",
            "example": "0192fb17-5dc6-7abc-8def-123456789abc"
          },
          "Status": {
            "type": "string",
            "enum": [
              "applied",
              "skipped_not_member",
              "invalid"
            ],
            "description": "Per-hotel outcome: 'applied' (a live project member, now tagged), 'skipped_not_member' (a valid id that is not a live member of the project; never tagged), or 'invalid' (a malformed / non-UUID id).",
            "example": "applied"
          }
        }
      },
      "BulkTagResult": {
        "type": "object",
        "required": [
          "TagID",
          "Results"
        ],
        "description": "The per-hotel outcomes of a bulk add.",
        "properties": {
          "TagID": {
            "type": "string",
            "format": "uuid",
            "description": "UUID of the tag that was applied.",
            "example": "0192fc01-1111-7abc-8def-aaaaaaaaaaaa"
          },
          "Results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BulkTagHotelResult"
            },
            "description": "One entry per submitted hotel id, in submission order."
          }
        }
      },
      "ErrorDetail": {
        "type": "object",
        "required": [
          "Code",
          "Message"
        ],
        "description": "Error detail containing a machine-readable code and human-readable message.",
        "properties": {
          "Code": {
            "type": "string",
            "description": "Machine-readable error code for programmatic handling.",
            "example": "VALIDATION_ERROR"
          },
          "Message": {
            "type": "string",
            "description": "Human-readable error message.",
            "example": "Request validation failed"
          },
          "Fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FieldError"
            },
            "description": "Field-level validation errors. Only present for VALIDATION_ERROR responses."
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
          "Error"
        ],
        "description": "Standard v2 error response wrapper.",
        "properties": {
          "Error": {
            "$ref": "#/components/schemas/ErrorDetail"
          }
        }
      },
      "FieldError": {
        "type": "object",
        "required": [
          "Field",
          "Message"
        ],
        "description": "A single field-level validation error.",
        "properties": {
          "Field": {
            "type": "string",
            "description": "Name of the field that failed validation.",
            "example": "HotelIDs"
          },
          "Message": {
            "type": "string",
            "description": "Human-readable validation error message for this field.",
            "example": "HotelIDs must not be empty"
          },
          "Code": {
            "type": "string",
            "enum": [
              "REQUIRED",
              "TOO_LONG",
              "TOO_SHORT",
              "OUT_OF_RANGE",
              "TOO_MANY",
              "INVALID_FORMAT",
              "NOT_ALLOWED",
              "CONFLICT",
              "INVALID_ENCODING",
              "INSECURE_SCHEME",
              "UNSAFE_CONTENT",
              "REQUIRED_WHEN_ENABLED"
            ],
            "description": "Machine-readable reason the field failed validation. Optional; clients should fall back to Message when it is absent or unrecognized.",
            "example": "TOO_LONG"
          },
          "Params": {
            "type": "object",
            "additionalProperties": true,
            "description": "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": {
              "Max": 100
            }
          }
        }
      }
    },
    "parameters": {
      "X-Project-ID": {
        "name": "X-Project-ID",
        "in": "header",
        "required": true,
        "description": "Project UUID. Required for all project-scoped endpoints.",
        "example": "$YGO_PROJECT_ID",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      }
    },
    "headers": {
      "Retry-After": {
        "description": "Number of seconds to wait before retrying the request. Present on 429 responses.",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "example": 30
        }
      },
      "X-Trace-ID": {
        "description": "Request trace ID for debugging (OpenTelemetry). Include this ID when contacting support about specific requests.",
        "schema": {
          "type": "string",
          "example": "abc123def456ghi789"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Bad Request - Validation error or invalid request body.",
        "headers": {
          "X-Trace-ID": {
            "$ref": "#/components/headers/X-Trace-ID"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "invalidTagID": {
                "summary": "TagID missing or not a valid UUID",
                "value": {
                  "Error": {
                    "Code": "VALIDATION_ERROR",
                    "Message": "Request validation failed",
                    "Fields": [
                      {
                        "Field": "TagID",
                        "Message": "TagID must be a valid UUID"
                      }
                    ]
                  }
                }
              },
              "emptyHotelIDs": {
                "summary": "HotelIDs is empty",
                "value": {
                  "Error": {
                    "Code": "VALIDATION_ERROR",
                    "Message": "Request validation failed",
                    "Fields": [
                      {
                        "Field": "HotelIDs",
                        "Message": "HotelIDs must not be empty"
                      }
                    ]
                  }
                }
              },
              "tooManyHotelIDs": {
                "summary": "HotelIDs exceeds the maximum of 1000",
                "value": {
                  "Error": {
                    "Code": "VALIDATION_ERROR",
                    "Message": "Request validation failed",
                    "Fields": [
                      {
                        "Field": "HotelIDs",
                        "Message": "HotelIDs exceeds the maximum of 1000"
                      }
                    ]
                  }
                }
              },
              "invalidBody": {
                "summary": "Malformed request body",
                "value": {
                  "Error": {
                    "Code": "VALIDATION_ERROR",
                    "Message": "Invalid request body"
                  }
                }
              }
            }
          }
        }
      },
      "Forbidden": {
        "description": "Forbidden - Valid API key but insufficient permissions for this operation. Also returned with code INSUFFICIENT_SCOPE when the API key does not carry the content.catalog:write permission this endpoint requires.",
        "headers": {
          "X-Trace-ID": {
            "$ref": "#/components/headers/X-Trace-ID"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "insufficientScope": {
                "summary": "Missing required scope",
                "value": {
                  "Error": {
                    "Code": "INSUFFICIENT_SCOPE",
                    "Message": "token lacks scope content.catalog:write"
                  }
                }
              },
              "noProjectAccess": {
                "summary": "Project access required",
                "value": {
                  "Error": {
                    "Code": "FORBIDDEN",
                    "Message": "Project access required"
                  }
                }
              }
            }
          }
        }
      },
      "InternalServerError": {
        "description": "Internal Server Error - Unexpected server error. Include the X-Trace-ID header value when contacting support.",
        "headers": {
          "X-Trace-ID": {
            "$ref": "#/components/headers/X-Trace-ID"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "internalError": {
                "summary": "Internal server error",
                "value": {
                  "Error": {
                    "Code": "INTERNAL_ERROR",
                    "Message": "Failed to verify hotel"
                  }
                }
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "Not Found - The tag does not exist or is not in the calling project's scope.",
        "headers": {
          "X-Trace-ID": {
            "$ref": "#/components/headers/X-Trace-ID"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "tagNotFound": {
                "summary": "Tag id not in the project (foreign tag)",
                "value": {
                  "Error": {
                    "Code": "NOT_FOUND",
                    "Message": "Tag not found"
                  }
                }
              }
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Too Many Requests. The response includes a `Retry-After` header with the number of seconds to wait before retrying.",
        "headers": {
          "X-Trace-ID": {
            "$ref": "#/components/headers/X-Trace-ID"
          },
          "Retry-After": {
            "$ref": "#/components/headers/Retry-After"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "rateLimited": {
                "summary": "Limit exceeded",
                "value": {
                  "Error": {
                    "Code": "RATE_LIMIT_EXCEEDED",
                    "Message": "Rate limit exceeded. Retry after the number of seconds in the Retry-After header."
                  }
                }
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Unauthorized - Invalid or missing API key.",
        "headers": {
          "X-Trace-ID": {
            "$ref": "#/components/headers/X-Trace-ID"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "invalidKey": {
                "summary": "Invalid API key",
                "value": {
                  "Error": {
                    "Code": "UNAUTHORIZED",
                    "Message": "Invalid API key"
                  }
                }
              }
            }
          }
        }
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Project-scoped API key"
      }
    }
  }
}
