{
  "openapi": "3.0.3",
  "info": {
    "title": "Rightwork Workforce API",
    "version": "1.0.0-preview",
    "description": "Controlled pilot. Confirm base URL, sandbox availability and access with Rightwork. See README for data and synchronization semantics."
  },
  "security": [
    {
      "IntegrationKey": []
    }
  ],
  "components": {
    "securitySchemes": {
      "IntegrationKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Opaque company integration key; not JWT or OAuth. Keys expire in 90 days."
      }
    }
  },
  "paths": {
    "/api/external/v1/connection": {
      "get": {
        "operationId": "get_connection",
        "summary": "Retrieve connection",
        "description": "Required scope: valid integration credential. Read-only; company/location boundaries derive from the credential.",
        "x-required-scope": null,
        "parameters": [],
        "responses": {
          "200": {
            "description": "Successful authorized read. Collections may be empty.",
            "headers": {
              "X-Request-ID": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "no-store"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "integration_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "name": {
                          "type": "string"
                        },
                        "company_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "company_name": {
                          "type": "string"
                        },
                        "environment": {
                          "type": "string"
                        },
                        "scopes": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "enum": [
                              "locations:read",
                              "employees:read",
                              "schedules:read",
                              "time_off:read",
                              "time_entries:read",
                              "reference:read"
                            ]
                          }
                        },
                        "expires_at": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "api_version": {
                          "type": "string",
                          "enum": [
                            "v1"
                          ]
                        },
                        "location_access": {
                          "type": "string",
                          "enum": [
                            "explicit_list"
                          ]
                        },
                        "capabilities": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "limits": {
                          "type": "object",
                          "properties": {
                            "reads_per_minute": {
                              "type": "integer"
                            },
                            "max_page_size": {
                              "type": "integer"
                            },
                            "max_window_days": {
                              "type": "integer"
                            },
                            "max_source_rows": {
                              "type": "integer"
                            },
                            "snapshot_seconds": {
                              "type": "integer"
                            },
                            "max_retained_snapshots": {
                              "type": "integer"
                            }
                          },
                          "required": [
                            "reads_per_minute",
                            "max_page_size",
                            "max_window_days",
                            "max_source_rows",
                            "snapshot_seconds",
                            "max_retained_snapshots"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "integration_id",
                        "name",
                        "company_id",
                        "company_name",
                        "environment",
                        "scopes",
                        "expires_at",
                        "api_version",
                        "location_access",
                        "capabilities",
                        "limits"
                      ],
                      "additionalProperties": false
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid filters or oversized export",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Invalid, revoked, expired or disabled credential",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "403": {
            "description": "Insufficient scope/location permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "409": {
            "description": "Ambiguous data or snapshot restart required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "429": {
            "description": "Rate or retained-snapshot limit",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds until retry."
              }
            }
          },
          "500": {
            "description": "Internal error; contact support with request ID",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "503": {
            "description": "Transient database failure; retry",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/api/external/v1/locations": {
      "get": {
        "operationId": "get_locations",
        "summary": "Retrieve locations",
        "description": "Required scope: locations:read. Read-only; company/location boundaries derive from the credential.",
        "x-required-scope": "locations:read",
        "parameters": [
          {
            "name": "page_size",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 100,
              "minimum": 1,
              "maximum": 500
            },
            "description": "Keep identical across all pages."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque next_cursor. Repeat the original filters exactly."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful authorized read. Collections may be empty.",
            "headers": {
              "X-Request-ID": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "no-store"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "name": {
                            "type": "string"
                          },
                          "timezone": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "open",
                              "closed"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "timezone",
                          "status"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "snapshot_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "as_of": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "scope_revision": {
                          "type": "string"
                        },
                        "next_cursor": {
                          "type": "string",
                          "nullable": true
                        },
                        "complete": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "request_id",
                        "snapshot_id",
                        "as_of",
                        "scope_revision",
                        "next_cursor",
                        "complete"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid filters or oversized export",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Invalid, revoked, expired or disabled credential",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "403": {
            "description": "Insufficient scope/location permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "409": {
            "description": "Ambiguous data or snapshot restart required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "429": {
            "description": "Rate or retained-snapshot limit",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds until retry."
              }
            }
          },
          "500": {
            "description": "Internal error; contact support with request ID",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "503": {
            "description": "Transient database failure; retry",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/api/external/v1/employees": {
      "get": {
        "operationId": "get_employees",
        "summary": "Retrieve employees",
        "description": "Required scope: employees:read. Read-only; company/location boundaries derive from the credential.",
        "x-required-scope": "employees:read",
        "parameters": [
          {
            "name": "page_size",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 100,
              "minimum": 1,
              "maximum": 500
            },
            "description": "Keep identical across all pages."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque next_cursor. Repeat the original filters exactly."
          },
          {
            "name": "employee_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Company-scoped employee UUID; mutually exclusive with payroll_external_id."
          },
          {
            "name": "payroll_external_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Exact payroll ID, preserving leading zeros. Ambiguous matches return 409."
          },
          {
            "name": "payroll_source",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "payroll_source_ukg",
                "payroll_source_paylocity"
              ]
            },
            "description": "Optional source discriminator."
          },
          {
            "name": "location_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Must be in the credential location grant."
          },
          {
            "name": "active",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            },
            "description": "At least one active authorized membership, or none. Omit for all."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful authorized read. Collections may be empty.",
            "headers": {
              "X-Request-ID": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "no-store"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "payroll_external_id": {
                            "type": "string",
                            "nullable": true
                          },
                          "payroll_source": {
                            "type": "string",
                            "nullable": true
                          },
                          "mapping_status": {
                            "type": "string",
                            "enum": [
                              "mapped",
                              "missing",
                              "duplicate"
                            ]
                          },
                          "first_name": {
                            "type": "string"
                          },
                          "last_name": {
                            "type": "string"
                          },
                          "memberships": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "location_id": {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                "active": {
                                  "type": "boolean"
                                }
                              },
                              "required": [
                                "location_id",
                                "active"
                              ],
                              "additionalProperties": false
                            }
                          }
                        },
                        "required": [
                          "id",
                          "payroll_external_id",
                          "payroll_source",
                          "mapping_status",
                          "first_name",
                          "last_name",
                          "memberships"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "snapshot_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "as_of": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "scope_revision": {
                          "type": "string"
                        },
                        "next_cursor": {
                          "type": "string",
                          "nullable": true
                        },
                        "complete": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "request_id",
                        "snapshot_id",
                        "as_of",
                        "scope_revision",
                        "next_cursor",
                        "complete"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid filters or oversized export",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Invalid, revoked, expired or disabled credential",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "403": {
            "description": "Insufficient scope/location permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "409": {
            "description": "Ambiguous data or snapshot restart required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "429": {
            "description": "Rate or retained-snapshot limit",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds until retry."
              }
            }
          },
          "500": {
            "description": "Internal error; contact support with request ID",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "503": {
            "description": "Transient database failure; retry",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/api/external/v1/roles": {
      "get": {
        "operationId": "get_roles",
        "summary": "Retrieve roles",
        "description": "Required scope: reference:read. Read-only; company/location boundaries derive from the credential.",
        "x-required-scope": "reference:read",
        "parameters": [
          {
            "name": "page_size",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 100,
              "minimum": 1,
              "maximum": 500
            },
            "description": "Keep identical across all pages."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque next_cursor. Repeat the original filters exactly."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful authorized read. Collections may be empty.",
            "headers": {
              "X-Request-ID": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "no-store"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "name": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "name"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "snapshot_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "as_of": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "scope_revision": {
                          "type": "string"
                        },
                        "next_cursor": {
                          "type": "string",
                          "nullable": true
                        },
                        "complete": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "request_id",
                        "snapshot_id",
                        "as_of",
                        "scope_revision",
                        "next_cursor",
                        "complete"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid filters or oversized export",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Invalid, revoked, expired or disabled credential",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "403": {
            "description": "Insufficient scope/location permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "409": {
            "description": "Ambiguous data or snapshot restart required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "429": {
            "description": "Rate or retained-snapshot limit",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds until retry."
              }
            }
          },
          "500": {
            "description": "Internal error; contact support with request ID",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "503": {
            "description": "Transient database failure; retry",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/api/external/v1/time-off-types": {
      "get": {
        "operationId": "get_time_off_types",
        "summary": "Retrieve time-off-types",
        "description": "Required scope: reference:read. Read-only; company/location boundaries derive from the credential.",
        "x-required-scope": "reference:read",
        "parameters": [
          {
            "name": "page_size",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 100,
              "minimum": 1,
              "maximum": 500
            },
            "description": "Keep identical across all pages."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque next_cursor. Repeat the original filters exactly."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful authorized read. Collections may be empty.",
            "headers": {
              "X-Request-ID": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "no-store"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "code": {
                            "type": "string",
                            "enum": [
                              "PTO",
                              "SICK",
                              "UNPAID"
                            ]
                          },
                          "name": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "code",
                          "name"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "snapshot_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "as_of": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "scope_revision": {
                          "type": "string"
                        },
                        "next_cursor": {
                          "type": "string",
                          "nullable": true
                        },
                        "complete": {
                          "type": "boolean"
                        },
                        "legacy_unspecified_type": {
                          "type": "string",
                          "nullable": true,
                          "enum": [
                            null
                          ]
                        }
                      },
                      "required": [
                        "request_id",
                        "snapshot_id",
                        "as_of",
                        "scope_revision",
                        "next_cursor",
                        "complete",
                        "legacy_unspecified_type"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid filters or oversized export",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Invalid, revoked, expired or disabled credential",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "403": {
            "description": "Insufficient scope/location permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "409": {
            "description": "Ambiguous data or snapshot restart required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "429": {
            "description": "Rate or retained-snapshot limit",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds until retry."
              }
            }
          },
          "500": {
            "description": "Internal error; contact support with request ID",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "503": {
            "description": "Transient database failure; retry",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/api/external/v1/schedules": {
      "get": {
        "operationId": "get_schedules",
        "summary": "Retrieve schedules",
        "description": "Required scope: schedules:read. Read-only; company/location boundaries derive from the credential.",
        "x-required-scope": "schedules:read",
        "parameters": [
          {
            "name": "page_size",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 100,
              "minimum": 1,
              "maximum": 500
            },
            "description": "Keep identical across all pages."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque next_cursor. Repeat the original filters exactly."
          },
          {
            "name": "employee_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Company-scoped employee UUID; mutually exclusive with payroll_external_id."
          },
          {
            "name": "payroll_external_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Exact payroll ID, preserving leading zeros. Ambiguous matches return 409."
          },
          {
            "name": "payroll_source",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "payroll_source_ukg",
                "payroll_source_paylocity"
              ]
            },
            "description": "Optional source discriminator."
          },
          {
            "name": "location_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Must be in the credential location grant."
          },
          {
            "name": "date_from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "Inclusive local business date (leave: calendar-date overlap)."
          },
          {
            "name": "date_to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "Exclusive end; positive window of at most 31 days."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful authorized read. Collections may be empty.",
            "headers": {
              "X-Request-ID": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "no-store"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "employee_id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "payroll_external_id": {
                            "type": "string",
                            "nullable": true
                          },
                          "payroll_source": {
                            "type": "string",
                            "nullable": true
                          },
                          "mapping_status": {
                            "type": "string",
                            "enum": [
                              "mapped",
                              "missing",
                              "duplicate"
                            ]
                          },
                          "location_id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "role_id": {
                            "type": "string",
                            "format": "uuid",
                            "nullable": true
                          },
                          "role_name": {
                            "type": "string",
                            "nullable": true
                          },
                          "business_date": {
                            "type": "string",
                            "format": "date"
                          },
                          "starts_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "ends_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "timezone": {
                            "type": "string"
                          },
                          "unpaid_meal_breaks": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "starts_at": {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                "ends_at": {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                "is_paid": {
                                  "type": "boolean"
                                }
                              },
                              "required": [
                                "starts_at",
                                "ends_at",
                                "is_paid"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "scheduled_work_minutes": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "id",
                          "employee_id",
                          "payroll_external_id",
                          "payroll_source",
                          "mapping_status",
                          "location_id",
                          "role_id",
                          "role_name",
                          "business_date",
                          "starts_at",
                          "ends_at",
                          "timezone",
                          "unpaid_meal_breaks",
                          "scheduled_work_minutes"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "snapshot_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "as_of": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "scope_revision": {
                          "type": "string"
                        },
                        "next_cursor": {
                          "type": "string",
                          "nullable": true
                        },
                        "complete": {
                          "type": "boolean"
                        },
                        "publication_history": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "location_id": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "role_type_filter": {
                                "type": "string",
                                "nullable": true
                              },
                              "date_from": {
                                "type": "string",
                                "format": "date"
                              },
                              "date_to": {
                                "type": "string",
                                "format": "date"
                              },
                              "published_at": {
                                "type": "string",
                                "format": "date-time"
                              }
                            },
                            "required": [
                              "location_id",
                              "role_type_filter",
                              "date_from",
                              "date_to",
                              "published_at"
                            ],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "request_id",
                        "snapshot_id",
                        "as_of",
                        "scope_revision",
                        "next_cursor",
                        "complete",
                        "publication_history"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid filters or oversized export",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Invalid, revoked, expired or disabled credential",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "403": {
            "description": "Insufficient scope/location permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "409": {
            "description": "Ambiguous data or snapshot restart required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "429": {
            "description": "Rate or retained-snapshot limit",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds until retry."
              }
            }
          },
          "500": {
            "description": "Internal error; contact support with request ID",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "503": {
            "description": "Transient database failure; retry",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/api/external/v1/time-off-requests": {
      "get": {
        "operationId": "get_time_off_requests",
        "summary": "Retrieve time-off-requests",
        "description": "Required scope: time_off:read. Read-only; company/location boundaries derive from the credential.",
        "x-required-scope": "time_off:read",
        "parameters": [
          {
            "name": "page_size",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 100,
              "minimum": 1,
              "maximum": 500
            },
            "description": "Keep identical across all pages."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque next_cursor. Repeat the original filters exactly."
          },
          {
            "name": "employee_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Company-scoped employee UUID; mutually exclusive with payroll_external_id."
          },
          {
            "name": "payroll_external_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Exact payroll ID, preserving leading zeros. Ambiguous matches return 409."
          },
          {
            "name": "payroll_source",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "payroll_source_ukg",
                "payroll_source_paylocity"
              ]
            },
            "description": "Optional source discriminator."
          },
          {
            "name": "location_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Must be in the credential location grant."
          },
          {
            "name": "date_from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "Inclusive local business date (leave: calendar-date overlap)."
          },
          {
            "name": "date_to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "Exclusive end; positive window of at most 31 days."
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "PTO",
                "SICK",
                "UNPAID",
                "unspecified"
              ]
            },
            "description": "Omit for all types; unspecified selects historical null/empty."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "PENDING",
                "APPROVED",
                "REJECTED",
                "RESCINDED"
              ]
            },
            "description": "Omit for all statuses."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful authorized read. Collections may be empty.",
            "headers": {
              "X-Request-ID": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "no-store"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "employee_id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "payroll_external_id": {
                            "type": "string",
                            "nullable": true
                          },
                          "payroll_source": {
                            "type": "string",
                            "nullable": true
                          },
                          "mapping_status": {
                            "type": "string",
                            "enum": [
                              "mapped",
                              "missing",
                              "duplicate"
                            ]
                          },
                          "type": {
                            "type": "string",
                            "nullable": true,
                            "enum": [
                              "PTO",
                              "SICK",
                              "UNPAID",
                              null
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "PENDING",
                              "APPROVED",
                              "REJECTED",
                              "RESCINDED"
                            ]
                          },
                          "date_from": {
                            "type": "string",
                            "format": "date"
                          },
                          "date_to": {
                            "type": "string",
                            "format": "date"
                          },
                          "is_partial_day": {
                            "type": "boolean"
                          },
                          "local_start": {
                            "type": "object",
                            "properties": {
                              "time": {
                                "type": "string",
                                "pattern": "^\\d{2}:\\d{2}$"
                              },
                              "day_offset": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "time",
                              "day_offset"
                            ],
                            "additionalProperties": false,
                            "nullable": true
                          },
                          "local_end": {
                            "type": "object",
                            "properties": {
                              "time": {
                                "type": "string",
                                "pattern": "^\\d{2}:\\d{2}$"
                              },
                              "day_offset": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "time",
                              "day_offset"
                            ],
                            "additionalProperties": false,
                            "nullable": true
                          },
                          "created_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "updated_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "locations": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                "timezone": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "id",
                                "timezone"
                              ],
                              "additionalProperties": false
                            }
                          }
                        },
                        "required": [
                          "id",
                          "employee_id",
                          "payroll_external_id",
                          "payroll_source",
                          "mapping_status",
                          "type",
                          "status",
                          "date_from",
                          "date_to",
                          "is_partial_day",
                          "local_start",
                          "local_end",
                          "created_at",
                          "updated_at",
                          "locations"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "snapshot_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "as_of": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "scope_revision": {
                          "type": "string"
                        },
                        "next_cursor": {
                          "type": "string",
                          "nullable": true
                        },
                        "complete": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "request_id",
                        "snapshot_id",
                        "as_of",
                        "scope_revision",
                        "next_cursor",
                        "complete"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid filters or oversized export",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Invalid, revoked, expired or disabled credential",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "403": {
            "description": "Insufficient scope/location permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "409": {
            "description": "Ambiguous data or snapshot restart required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "429": {
            "description": "Rate or retained-snapshot limit",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds until retry."
              }
            }
          },
          "500": {
            "description": "Internal error; contact support with request ID",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "503": {
            "description": "Transient database failure; retry",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/api/external/v1/time-entries": {
      "get": {
        "operationId": "get_time_entries",
        "summary": "Retrieve time-entries",
        "description": "Required scope: time_entries:read. Read-only; company/location boundaries derive from the credential.",
        "x-required-scope": "time_entries:read",
        "parameters": [
          {
            "name": "page_size",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 100,
              "minimum": 1,
              "maximum": 500
            },
            "description": "Keep identical across all pages."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque next_cursor. Repeat the original filters exactly."
          },
          {
            "name": "employee_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Company-scoped employee UUID; mutually exclusive with payroll_external_id."
          },
          {
            "name": "payroll_external_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Exact payroll ID, preserving leading zeros. Ambiguous matches return 409."
          },
          {
            "name": "payroll_source",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "payroll_source_ukg",
                "payroll_source_paylocity"
              ]
            },
            "description": "Optional source discriminator."
          },
          {
            "name": "location_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Must be in the credential location grant."
          },
          {
            "name": "date_from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "Inclusive local business date (leave: calendar-date overlap)."
          },
          {
            "name": "date_to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "Exclusive end; positive window of at most 31 days."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful authorized read. Collections may be empty.",
            "headers": {
              "X-Request-ID": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "no-store"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "employee_id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "payroll_external_id": {
                            "type": "string",
                            "nullable": true
                          },
                          "payroll_source": {
                            "type": "string",
                            "nullable": true
                          },
                          "mapping_status": {
                            "type": "string",
                            "enum": [
                              "mapped",
                              "missing",
                              "duplicate"
                            ]
                          },
                          "location_id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "role_id": {
                            "type": "string",
                            "format": "uuid",
                            "nullable": true
                          },
                          "business_date": {
                            "type": "string",
                            "format": "date"
                          },
                          "timezone": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "pending",
                              "auto_approved",
                              "auto_flag",
                              "manual_approved",
                              "manual_denied",
                              "pay_period_published"
                            ]
                          },
                          "clocked_in_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "clocked_out_at": {
                            "type": "string",
                            "format": "date-time",
                            "nullable": true
                          },
                          "elapsed_minutes": {
                            "type": "number",
                            "nullable": true
                          },
                          "minutes_less_unpaid_breaks": {
                            "type": "number",
                            "nullable": true
                          },
                          "breaks": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                "starts_at": {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                "ends_at": {
                                  "type": "string",
                                  "format": "date-time",
                                  "nullable": true
                                },
                                "is_paid": {
                                  "type": "boolean"
                                }
                              },
                              "required": [
                                "id",
                                "starts_at",
                                "ends_at",
                                "is_paid"
                              ],
                              "additionalProperties": false
                            }
                          }
                        },
                        "required": [
                          "id",
                          "employee_id",
                          "payroll_external_id",
                          "payroll_source",
                          "mapping_status",
                          "location_id",
                          "role_id",
                          "business_date",
                          "timezone",
                          "status",
                          "clocked_in_at",
                          "clocked_out_at",
                          "elapsed_minutes",
                          "minutes_less_unpaid_breaks",
                          "breaks"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "snapshot_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "as_of": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "scope_revision": {
                          "type": "string"
                        },
                        "next_cursor": {
                          "type": "string",
                          "nullable": true
                        },
                        "complete": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "request_id",
                        "snapshot_id",
                        "as_of",
                        "scope_revision",
                        "next_cursor",
                        "complete"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid filters or oversized export",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Invalid, revoked, expired or disabled credential",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "403": {
            "description": "Insufficient scope/location permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "409": {
            "description": "Ambiguous data or snapshot restart required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "429": {
            "description": "Rate or retained-snapshot limit",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds until retry."
              }
            }
          },
          "500": {
            "description": "Internal error; contact support with request ID",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "503": {
            "description": "Transient database failure; retry",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "request_id": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "code",
                        "message",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    }
  }
}
