---
title: "Log a file access event"
method: POST
path: "/file-events"
tags: ["Create file access event"]
---

# Log a file access event

`POST /file-events`

## Request

- Base URL: `http://localhost:26900`
- URL: `http://localhost:26900/file-events`
- Auth: API key in header `Authorization`

## Request body

- Event: Details of a specific file access event forming part of the audit log for users downloading a file.
  - `created_at` string, date-time: The date and time the event occurred.
  - `requested_by` object, required: The user who made the request.
    - `id` string, required: The ID of the user.
    - `email` string, email: The email of the user. This is only populated if the user is a human user.
  - `action` 'CREATE' | 'READ' | 'UPDATE' | 'DELETE', required: The action taken by the user.
  - `resource` string, required: The path of the API resource that was called.
  - `file` MetaData, required: File metadata
    - `path` string: Path to file
    - `is_publishable` boolean: Is the file publishable
    - `collection_id` string: The collection ID to which the file is attached
    - `bundle_id` string: The bundle ID to which the file is attached
    - `title` string: The title given to the file
    - `size_in_bytes` integer: Size of the file in bytes
    - `type` string: The file type
    - `licence` string: The type of licence the file has
    - `licence_url` string: Licence URL
    - `etag` string: File etag
    - `state` string: File state
    - `content_item` object: Dataset information that the file relates to
      - `dataset_id` string: The dataset ID
      - `edition` string: The edition
      - `version` string: The version

## Response `201`

File access event successfully created

- Event: Details of a specific file access event forming part of the audit log for users downloading a file.
  - `created_at` string, date-time: The date and time the event occurred.
  - `requested_by` object, required: The user who made the request.
    - `id` string, required: The ID of the user.
    - `email` string, email: The email of the user. This is only populated if the user is a human user.
  - `action` 'CREATE' | 'READ' | 'UPDATE' | 'DELETE', required: The action taken by the user.
  - `resource` string, required: The path of the API resource that was called.
  - `file` MetaData, required: File metadata
    - `path` string: Path to file
    - `is_publishable` boolean: Is the file publishable
    - `collection_id` string: The collection ID to which the file is attached
    - `bundle_id` string: The bundle ID to which the file is attached
    - `title` string: The title given to the file
    - `size_in_bytes` integer: Size of the file in bytes
    - `type` string: The file type
    - `licence` string: The type of licence the file has
    - `licence_url` string: Licence URL
    - `etag` string: File etag
    - `state` string: File state
    - `content_item` object: Dataset information that the file relates to
      - `dataset_id` string: The dataset ID
      - `edition` string: The edition
      - `version` string: The version

## Other responses

- `400`: Unable to process request due to a malformed or invalid request body or query parameter.
- `401`: Authentication information is missing or invalid.
- `403`: Access denied.
- `500`: Failed to process the request due to an internal error

---

[API](https://skmtc.dev/office-of-national-statistics/apis/files-api.md) - [All operations](https://skmtc.dev/office-of-national-statistics/apis/files-api/llms.txt) - [OpenAPI document](https://skmtc.dev/office-of-national-statistics/apis/files-api/revisions/b34c9662a495?raw)
