Goatlab API Docs

Replace metadata for a file in a space

PATCH
/v1/spaces/{spaceId}/files/{fileId}/metadata

Replaces the metadata fields of a file within a space with the provided set.

You must provide the space ID and file ID in the path and the user ID, tenant ID in the headers.

Behavior:

  • The payload is the complete metadata set: any existing field whose key is not included is removed.
  • Send an empty array to clear all metadata.
  • aiExtracted marks whether the value was produced by AI (defaults to false).

Validation:

  • Each key is required and must be non-empty.
  • Each value is required and must be a non-empty string (null is not allowed).
  • Keys must be unique within the payload.
  • A maximum of 15 fields is allowed.

Access Control:

Access to update file metadata in a space depends on your permissions and the space's visibility:

  • Private Spaces: Only accessible by the space owner
  • Public Spaces: Accessible by all users within the same tenant

Authorization

ApiTokenAuth PRODUCT
x-api-key<token>

API Key with role based permission

In: header

Scope: PRODUCT

Path Parameters

spaceId*string

The unique identifier of the space containing the file

fileId*string

The unique identifier of the file whose metadata is being replaced

Header Parameters

x-user-id*string

The ID of the user requesting the update

x-tenant-id*string

The ID of the tenant

Request Body

application/json

The full set of metadata fields to store for the file

TypeScript Definitions

Use the request body type in TypeScript.

The full set of metadata fields for the file. This replaces the current metadata: any existing field whose key is not present in the payload is removed. Send an empty array to clear all metadata.

[index: integer]?

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

curl -X PATCH "https://example.com/v1/spaces/497f6eca-6276-4993-bfeb-53cbbbba6f08/files/497f6eca-6276-4993-bfeb-53cbbbba6f08/metadata" \  -H "x-user-id: string" \  -H "x-tenant-id: string" \  -H "Content-Type: application/json" \  -d '[    {      "key": "author",      "value": "Jane Doe",      "aiExtracted": false    },    {      "key": "topic",      "value": "finance",      "aiExtracted": true    },    {      "key": "fiscal_year",      "value": "2023"    }  ]'
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "summary": "Quarterly financial overview",
  "language": "en",
  "documentKind": "Report",
  "domain": "Finance",
  "tags": [
    {
      "key": "author",
      "value": "Jane Doe",
      "aiExtracted": false
    },
    {
      "key": "topic",
      "value": "finance",
      "aiExtracted": true
    },
    {
      "key": "fiscal_year",
      "value": "2023",
      "aiExtracted": false
    }
  ]
}
{
  "message": {
    "description": "Validation failed",
    "errors": [
      {
        "path": "body.0.key",
        "message": "Key is required"
      }
    ]
  }
}
{
  "message": "Invalid API Key"
}
{
  "message": "API Key does not have permission to access this resource"
}

{
  "message": "Space not found"
}

{
  "message": "Internal Server Error"
}