---
title: "Upload a file to a page"
method: POST
path: "/api/pages/{id}/attachments"
tags: ["attachments"]
---

# Upload a file to a page

`POST /api/pages/{id}/attachments`

## Request

- Base URL: `https://telawiki.com`
- URL: `https://telawiki.com/api/pages/{id}/attachments`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `tela_session`

`editor+`. `multipart/form-data` with one part named `file`. Default size limit 50 MiB, configurable per instance. Storage is content-addressed, so re-uploading identical bytes is cheap.

## Response `200`

Stored. Note this is 200, not 201.

- object
  - `attachment` Attachment, required
    - `id` integer, required
    - `name` string, required
    - `mime` string, required
    - `byte_size` integer, required
    - `hash` string, required: SHA-256 of the content, 64 lower-case hex characters.
    - `url` string, required: Relative path to the bytes: `/api/files/{space_id}/{hash}{ext}`.
    - `share_path` string, required: Relative path to the human-facing file page: `/f/{hash12}/{name}`.
    - `embedded` boolean, required: Whether the page body references this file.
    - `summary` string: Generated description, when one exists.

## Other responses

- `400`: Malformed request. `code` is usually `bad_request` or `invalid_json`.
- `402`: `quota_exceeded` — a plan limit (pages, storage) was reached.
- `403`: `forbidden` (no access, or the role is too low), `viewer_no_write`, `api_key_scope` (the token's scope forbids this method), or `api_key_space_scope` (the token is pinned to another space).
- `413`: `too_large` — the upload exceeds the instance's file size limit (50 MiB by default).
- `500`: `internal` — server error.

---

[API](https://skmtc.dev/telawiki/apis/tela-rest-api.md) · [All operations](https://skmtc.dev/telawiki/apis/tela-rest-api/llms.txt) · [OpenAPI document](https://skmtc.dev/telawiki/apis/tela-rest-api/revisions/f316f31f6fcb?raw)
