{
  "swagger": "2.0",
  "info": {
    "title": "Attachment service",
    "version": "0.1507.0",
    "description": "Send your API key as a bearer token: `Authorization: Bearer <api key>`."
  },
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "securityDefinitions": {
    "ApiKey": {
      "type": "apiKey",
      "in": "header",
      "name": "Authorization",
      "description": "Your API key as a bearer token: `Authorization: Bearer <api key>`."
    }
  },
  "security": [
    {
      "ApiKey": []
    }
  ],
  "paths": {
    "/attachments/v1/attachments": {
      "post": {
        "operationId": "AttachmentService_create",
        "summary": "Create",
        "tags": [
          "Attachment Service"
        ],
        "description": "Create a new attachment. Assumes the file is already uploaded to S3 through the upload service.",
        "parameters": [
          {
            "name": "request",
            "in": "body",
            "schema": {
              "$ref": "#/definitions/CreateAttachmentRequest"
            },
            "required": true,
            "x-example": {
              "s3Path": "<s3 path>",
              "title": "<title>",
              "description": "<description>"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/Attachment"
            },
            "x-example": {
              "rid": "<attachment rid>",
              "title": "<title>",
              "s3Path": "<s3 path>",
              "fileType": "<file type>",
              "description": "<description>",
              "createdBy": "<created by>",
              "properties": {
                "<key>": "<property value>"
              },
              "labels": [
                "<label>"
              ],
              "createdAt": "2026-01-01T00:00:00Z",
              "isArchived": true
            }
          }
        }
      }
    },
    "/attachments/v1/attachments/{rid}": {
      "get": {
        "operationId": "AttachmentService_get",
        "summary": "Get",
        "tags": [
          "Attachment Service"
        ],
        "description": "Get an attachment by its RID.",
        "parameters": [
          {
            "name": "rid",
            "in": "path",
            "type": "string",
            "format": "rid",
            "x-alias": "AttachmentRid",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/Attachment"
            },
            "x-example": {
              "rid": "<attachment rid>",
              "title": "<title>",
              "s3Path": "<s3 path>",
              "fileType": "<file type>",
              "description": "<description>",
              "createdBy": "<created by>",
              "properties": {
                "<key>": "<property value>"
              },
              "labels": [
                "<label>"
              ],
              "createdAt": "2026-01-01T00:00:00Z",
              "isArchived": true
            }
          }
        }
      },
      "put": {
        "operationId": "AttachmentService_update",
        "summary": "Update",
        "tags": [
          "Attachment Service"
        ],
        "description": "Update an attachment. Only the fields that are set in the request will be updated.",
        "parameters": [
          {
            "name": "rid",
            "in": "path",
            "type": "string",
            "format": "rid",
            "x-alias": "AttachmentRid",
            "required": true
          },
          {
            "name": "request",
            "in": "body",
            "schema": {
              "$ref": "#/definitions/UpdateAttachmentRequest"
            },
            "required": true,
            "x-example": {
              "title": "<title>",
              "description": "<description>",
              "properties": {
                "<key>": "<property value>"
              },
              "labels": [
                "<label>"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/Attachment"
            },
            "x-example": {
              "rid": "<attachment rid>",
              "title": "<title>",
              "s3Path": "<s3 path>",
              "fileType": "<file type>",
              "description": "<description>",
              "createdBy": "<created by>",
              "properties": {
                "<key>": "<property value>"
              },
              "labels": [
                "<label>"
              ],
              "createdAt": "2026-01-01T00:00:00Z",
              "isArchived": true
            }
          }
        }
      }
    },
    "/attachments/v1/attachments/batch": {
      "post": {
        "operationId": "AttachmentService_getBatch",
        "summary": "Get batch",
        "tags": [
          "Attachment Service"
        ],
        "description": "Get a set of attachments by their RIDs.",
        "parameters": [
          {
            "name": "request",
            "in": "body",
            "schema": {
              "$ref": "#/definitions/GetAttachmentsRequest"
            },
            "required": true,
            "x-example": {
              "attachmentRids": [
                "<attachment rid>"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/GetAttachmentsResponse"
            },
            "x-example": {
              "response": [
                {
                  "rid": "<attachment rid>",
                  "title": "<title>",
                  "s3Path": "<s3 path>",
                  "fileType": "<file type>",
                  "description": "<description>",
                  "createdBy": "<created by>",
                  "properties": {
                    "<key>": "<property value>"
                  },
                  "labels": [
                    "<label>"
                  ],
                  "createdAt": "2026-01-01T00:00:00Z",
                  "isArchived": true
                }
              ]
            }
          }
        }
      }
    },
    "/attachments/v1/attachments/{rid}/content": {
      "get": {
        "operationId": "AttachmentService_getContent",
        "summary": "Get content",
        "tags": [
          "Attachment Service"
        ],
        "description": "Get the binary content of an attachment.",
        "parameters": [
          {
            "name": "rid",
            "in": "path",
            "type": "string",
            "format": "rid",
            "x-alias": "AttachmentRid",
            "required": true
          }
        ],
        "produces": [
          "application/octet-stream"
        ],
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "type": "string",
              "format": "binary"
            }
          }
        }
      }
    },
    "/attachments/v1/attachments/{rid}/uri": {
      "get": {
        "operationId": "AttachmentService_getUri",
        "summary": "Get uri",
        "tags": [
          "Attachment Service"
        ],
        "description": "Get a pre-signed URI to download an attachment. The link expires in 1 minute.",
        "parameters": [
          {
            "name": "rid",
            "in": "path",
            "type": "string",
            "format": "rid",
            "x-alias": "AttachmentRid",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/AttachmentUri"
            },
            "x-example": {
              "uri": "<uri>"
            }
          }
        }
      }
    },
    "/attachments/v1/attachments/{rid}/archive": {
      "put": {
        "operationId": "AttachmentService_archive",
        "summary": "Archive",
        "tags": [
          "Attachment Service"
        ],
        "description": "Archive an attachment.",
        "parameters": [
          {
            "name": "rid",
            "in": "path",
            "type": "string",
            "format": "rid",
            "x-alias": "AttachmentRid",
            "required": true
          }
        ],
        "responses": {
          "204": {
            "description": "No content."
          }
        }
      }
    },
    "/attachments/v1/attachments/{rid}/unarchive": {
      "put": {
        "operationId": "AttachmentService_unarchive",
        "summary": "Unarchive",
        "tags": [
          "Attachment Service"
        ],
        "description": "Unarchive an attachment.",
        "parameters": [
          {
            "name": "rid",
            "in": "path",
            "type": "string",
            "format": "rid",
            "x-alias": "AttachmentRid",
            "required": true
          }
        ],
        "responses": {
          "204": {
            "description": "No content."
          }
        }
      }
    }
  },
  "definitions": {
    "Attachment": {
      "type": "object",
      "properties": {
        "rid": {
          "type": "string",
          "format": "rid",
          "x-alias": "AttachmentRid"
        },
        "title": {
          "type": "string"
        },
        "s3Path": {
          "type": "string",
          "x-alias": "S3Path"
        },
        "fileType": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "createdBy": {
          "type": "string",
          "format": "rid"
        },
        "properties": {
          "type": "object",
          "additionalProperties": {
            "type": "string",
            "x-alias": "PropertyValue"
          },
          "x-map-key": "PropertyName"
        },
        "labels": {
          "type": "array",
          "items": {
            "type": "string",
            "x-alias": "Label"
          },
          "uniqueItems": true
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "isArchived": {
          "type": "boolean"
        }
      },
      "required": [
        "rid",
        "title",
        "s3Path",
        "fileType",
        "description",
        "createdBy",
        "createdAt",
        "isArchived"
      ]
    },
    "AttachmentUri": {
      "description": "Pre-signed URI that will download the attachment directly from S3. Expires if the download has not started in 1 minute.",
      "type": "object",
      "properties": {
        "uri": {
          "type": "string"
        }
      },
      "required": [
        "uri"
      ]
    },
    "CreateAttachmentRequest": {
      "type": "object",
      "properties": {
        "s3Path": {
          "type": "string",
          "x-alias": "S3Path"
        },
        "title": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "properties": {
          "type": "object",
          "additionalProperties": {
            "type": "string",
            "x-alias": "PropertyValue"
          },
          "x-map-key": "PropertyName"
        },
        "labels": {
          "type": "array",
          "items": {
            "type": "string",
            "x-alias": "Label"
          },
          "uniqueItems": true
        },
        "workspace": {
          "type": "string",
          "format": "rid",
          "x-alias": "WorkspaceRid",
          "description": "The workspace in which to create the attachment. If not provided, the attachment will be created in the default workspace for the user's organization, if the default workspace for the organization is configured."
        }
      },
      "required": [
        "s3Path",
        "title",
        "description"
      ],
      "example": {
        "s3Path": "<s3 path>",
        "title": "<title>",
        "description": "<description>"
      }
    },
    "GetAttachmentsRequest": {
      "type": "object",
      "properties": {
        "attachmentRids": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "rid",
            "x-alias": "AttachmentRid"
          },
          "uniqueItems": true
        }
      },
      "example": {
        "attachmentRids": [
          "<attachment rid>"
        ]
      }
    },
    "GetAttachmentsResponse": {
      "type": "object",
      "properties": {
        "response": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Attachment"
          },
          "uniqueItems": true
        }
      }
    },
    "UpdateAttachmentRequest": {
      "type": "object",
      "properties": {
        "title": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "properties": {
          "type": "object",
          "additionalProperties": {
            "type": "string",
            "x-alias": "PropertyValue"
          },
          "x-map-key": "PropertyName"
        },
        "labels": {
          "type": "array",
          "items": {
            "type": "string",
            "x-alias": "Label"
          },
          "uniqueItems": true
        }
      },
      "example": {
        "title": "<title>",
        "description": "<description>",
        "properties": {
          "<key>": "<property value>"
        },
        "labels": [
          "<label>"
        ]
      }
    }
  },
  "tags": [
    {
      "name": "Attachment Service",
      "x-displayName": "Attachment service",
      "description": "The attachment service provides functionality for creating, updating, and archiving attachments uploaded to S3.",
      "x-errors": [
        {
          "status": 404,
          "errorCode": "NOT_FOUND",
          "errorName": "Attachment:AttachmentNotFound"
        },
        {
          "status": 404,
          "errorCode": "NOT_FOUND",
          "errorName": "Attachment:AttachmentsNotFound"
        },
        {
          "status": 404,
          "errorCode": "NOT_FOUND",
          "errorName": "Attachment:S3FileNotFound"
        },
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "Attachment:InvalidS3Path"
        }
      ]
    }
  ]
}
