{
  "openapi": "3.1.0",
  "info": {
    "title": "SynckHub Repository Integration API",
    "version": "1.0.0",
    "description": "Stable machine-to-machine read API for repository inventory, filtered search, permissions, file bytes, and file history. Exchange a repo API token with SynckHub Common for a short-lived access token, then send that access token as a bearer token to these endpoints."
  },
  "servers": [
    {
      "url": "{apiBaseUrl}",
      "variables": {
        "apiBaseUrl": {
          "default": "https://api.example.synckhub.com",
          "description": "The repository API base URL returned by Common API-token exchange."
        }
      }
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Discovery"
    },
    {
      "name": "Items"
    },
    {
      "name": "Content"
    },
    {
      "name": "Permissions"
    }
  ],
  "paths": {
    "/openapi/integration-v1.json": {
      "get": {
        "operationId": "getIntegrationOpenApi",
        "summary": "Get this OpenAPI document",
        "tags": [
          "Discovery"
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "OpenAPI 3.1 document",
            "content": {
              "application/vnd.oai.openapi+json;version=3.1": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/repos/{repo_id}/items": {
      "get": {
        "operationId": "listItems",
        "summary": "List repository items",
        "description": "Lists visible items. Omit parent_folder_id for a repository-wide inventory. For stable cursor paging, use sort=name, order=asc, and pass both values from next_cursor as after_name and after_item_id.",
        "tags": [
          "Items"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/RepoId"
          },
          {
            "name": "parent_folder_id",
            "in": "query",
            "description": "Parent folder ID. An empty value selects repository-root children; omit for all visible repository items.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "item_type",
            "in": "query",
            "description": "Repeatable item-type filter, for example FILE or FOLDER.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "style": "form",
            "explode": true
          },
          {
            "name": "file_extension",
            "in": "query",
            "description": "Repeatable lowercase extension filter. Requires item_type=FILE.",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "style": "form",
            "explode": true
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "name",
                "date",
                "modified",
                "size",
                "extension"
              ],
              "default": "name"
            }
          },
          {
            "name": "order",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "asc"
            }
          },
          {
            "name": "after_name",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "after_item_id",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/ItemList"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/repos/{repo_id}/items/search": {
      "get": {
        "operationId": "searchItems",
        "summary": "Search and filter repository items",
        "description": "The q parameter is optional. Omit it to use this endpoint as a filtered inventory. Set parent_folder_id and recursive=true to constrain results to a folder subtree.",
        "tags": [
          "Items"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/RepoId"
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "parent_folder_id",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "recursive",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "item_type",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "file_extension",
            "in": "query",
            "description": "Comma-separated lowercase file extensions.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "updated_by",
            "in": "query",
            "description": "Comma-separated actor IDs.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "updated_at_from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "updated_at_to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "name",
                "date",
                "modified",
                "size",
                "extension",
                "location"
              ]
            }
          },
          {
            "name": "order",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/ItemList"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/repos/{repo_id}/items/{item_id}": {
      "get": {
        "operationId": "getItem",
        "summary": "Get item metadata",
        "tags": [
          "Items"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/RepoId"
          },
          {
            "$ref": "#/components/parameters/ItemId"
          }
        ],
        "responses": {
          "200": {
            "description": "Item metadata",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Item"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/repos/{repo_id}/items/{item_id}/content": {
      "get": {
        "operationId": "downloadItem",
        "summary": "Download current file bytes",
        "description": "Returns the stored file bytes, not derived text.",
        "tags": [
          "Content"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/RepoId"
          },
          {
            "$ref": "#/components/parameters/ItemId"
          }
        ],
        "responses": {
          "200": {
            "description": "Raw file bytes",
            "headers": {
              "Content-Length": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/repos/{repo_id}/items/{item_id}/content-url": {
      "get": {
        "operationId": "getItemDownloadUrl",
        "summary": "Create a short-lived download URL",
        "tags": [
          "Content"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/RepoId"
          },
          {
            "$ref": "#/components/parameters/ItemId"
          }
        ],
        "responses": {
          "200": {
            "description": "Short-lived download URL",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DownloadUrl"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/repos/{repo_id}/items/{item_id}/content-revisions": {
      "get": {
        "operationId": "getItemVersions",
        "summary": "List file content revisions",
        "description": "Lists immutable content revisions. Named business labels are available from the file-versions endpoint.",
        "tags": [
          "Content"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/RepoId"
          },
          {
            "$ref": "#/components/parameters/ItemId"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "Content revisions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ContentRevision"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/repos/{repo_id}/items/{item_id}/content-revisions/{item_seq}": {
      "get": {
        "operationId": "getVersion",
        "summary": "Get one file content revision",
        "description": "Returns revision metadata and blob_id. Download the revision bytes from the blob endpoint.",
        "tags": [
          "Content"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/RepoId"
          },
          {
            "$ref": "#/components/parameters/ItemId"
          },
          {
            "$ref": "#/components/parameters/ItemSeq"
          }
        ],
        "responses": {
          "200": {
            "description": "Content revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContentRevisionDetail"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/repos/{repo_id}/items/{item_id}/file-versions": {
      "get": {
        "operationId": "listNamedFileVersions",
        "summary": "List named file versions",
        "tags": [
          "Content"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/RepoId"
          },
          {
            "$ref": "#/components/parameters/ItemId"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "Named file versions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/NamedFileVersion"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/repos/{repo_id}/blobs/{blob_id}": {
      "get": {
        "operationId": "downloadBlob",
        "summary": "Download bytes for a resolved content revision",
        "description": "Use blob IDs returned by version endpoints. Authorization is still evaluated in the repository context.",
        "tags": [
          "Content"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/RepoId"
          },
          {
            "name": "blob_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Raw blob bytes",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/repos/{repo_id}/authz/effective/self": {
      "get": {
        "operationId": "getItemPermissions",
        "summary": "Get the caller's effective permissions",
        "description": "Select at most one target. Omit all target parameters for repository permissions, pass folder_id for a folder, or item_id for an item.",
        "tags": [
          "Permissions"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/RepoId"
          },
          {
            "name": "folder_id",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "item_id",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Effective permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EffectivePermissions"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Short-lived access token returned by the Common API token exchange. Do not send the long-lived opaque repo API token to repository endpoints."
      }
    },
    "parameters": {
      "RepoId": {
        "name": "repo_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "ItemId": {
        "name": "item_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "ItemSeq": {
        "name": "item_seq",
        "in": "path",
        "required": true,
        "schema": {
          "type": "integer",
          "format": "int64",
          "minimum": 1
        }
      },
      "Limit": {
        "name": "limit",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": 1
        }
      },
      "Offset": {
        "name": "offset",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": 0,
          "default": 0
        }
      }
    },
    "responses": {
      "ItemList": {
        "description": "Item page",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ItemList"
            }
          }
        }
      },
      "Error": {
        "description": "Request failed",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "Item": {
        "type": "object",
        "required": [
          "repo_id",
          "item_id",
          "item_type",
          "name",
          "parent_folder_id",
          "path",
          "lifecycle_state"
        ],
        "properties": {
          "repo_id": {
            "type": "string"
          },
          "item_id": {
            "type": "string"
          },
          "item_type": {
            "type": "string"
          },
          "item_subtype": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "file_extension": {
            "type": [
              "string",
              "null"
            ]
          },
          "parent_folder_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "path": {
            "type": "string"
          },
          "lifecycle_state": {
            "type": "string",
            "enum": [
              "LIVE",
              "TRASH",
              "TOMBSTONED"
            ]
          },
          "size": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "head_revision_item_seq": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "metadata_json": true,
          "last_updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "last_updated_by": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": true
      },
      "ItemList": {
        "type": "object",
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Item"
            }
          },
          "next_cursor": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ListCursor"
              },
              {
                "type": "null"
              }
            ]
          },
          "page": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      },
      "ListCursor": {
        "type": "object",
        "required": [
          "after_name",
          "after_item_id"
        ],
        "properties": {
          "after_name": {
            "type": "string"
          },
          "after_item_id": {
            "type": "string"
          }
        }
      },
      "DownloadUrl": {
        "type": "object",
        "required": [
          "url",
          "path",
          "expires_at",
          "download_name",
          "blob_id",
          "size_bytes"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri"
          },
          "path": {
            "type": "string"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "download_name": {
            "type": "string"
          },
          "blob_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "size_bytes": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "ContentRevision": {
        "type": "object",
        "required": [
          "repo_id",
          "item_id",
          "item_seq",
          "commit_id",
          "event_type",
          "file_name",
          "revision_origin",
          "updated_at",
          "updated_by",
          "suppression_state"
        ],
        "properties": {
          "repo_id": {
            "type": "string"
          },
          "item_id": {
            "type": "string"
          },
          "item_seq": {
            "type": "integer",
            "format": "int64"
          },
          "commit_id": {
            "type": "string"
          },
          "event_type": {
            "type": "string"
          },
          "file_name": {
            "type": "string"
          },
          "revision_origin": {
            "type": "string",
            "enum": [
              "LOCAL",
              "FEDERATED"
            ]
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_by": {
            "type": "string"
          },
          "suppression_state": {
            "type": "string",
            "enum": [
              "AVAILABLE",
              "SUPPRESSED"
            ]
          }
        },
        "additionalProperties": true
      },
      "ContentRevisionDetail": {
        "type": "object",
        "required": [
          "repo_id",
          "item_id",
          "item_seq",
          "blob_id",
          "commit_id",
          "commit_event_idx",
          "updated_at",
          "updated_by",
          "suppression_state"
        ],
        "properties": {
          "repo_id": {
            "type": "string"
          },
          "item_id": {
            "type": "string"
          },
          "item_seq": {
            "type": "integer",
            "format": "int64"
          },
          "blob_id": {
            "type": "string"
          },
          "size": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "commit_id": {
            "type": "string"
          },
          "commit_event_idx": {
            "type": "integer"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_by": {
            "type": "string"
          },
          "suppression_state": {
            "type": "string",
            "enum": [
              "AVAILABLE",
              "SUPPRESSED"
            ]
          }
        },
        "additionalProperties": true
      },
      "NamedFileVersion": {
        "type": "object",
        "required": [
          "repo_id",
          "item_id",
          "version_id",
          "lifecycle_state",
          "kind",
          "label_source",
          "blob_id"
        ],
        "properties": {
          "repo_id": {
            "type": "string"
          },
          "item_id": {
            "type": "string"
          },
          "version_id": {
            "type": "string"
          },
          "lifecycle_state": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "label_source": {
            "type": "string",
            "enum": [
              "INTERNAL",
              "EXTERNAL"
            ]
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "comment": {
            "type": [
              "string",
              "null"
            ]
          },
          "blob_id": {
            "type": "string"
          },
          "size": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "source_item_seq": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          }
        },
        "additionalProperties": true
      },
      "EffectivePermissions": {
        "type": "object",
        "required": [
          "principal_id",
          "resource_kind",
          "resource_id",
          "allowed_actions"
        ],
        "properties": {
          "principal_id": {
            "type": "string"
          },
          "resource_kind": {
            "type": "string",
            "enum": [
              "REPO",
              "FOLDER",
              "ITEM"
            ]
          },
          "resource_id": {
            "type": "string"
          },
          "allowed_actions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    }
  }
}
