POST /uploads
Updated Oct 1, 20261 minute read
Upload a file
The request body is the file itself, up to 20 MB. Send the real Content-Type, since the stored type comes from it. Returns the id to send in a message's attachments, and the size and type it stored. The name is cut to 200 characters. HTML, XHTML, SVG and XSLT files upload, but a message that attaches one is refused. A message can be attachments alone with an empty body, and threads return each attachment with a download url.
Part of Files.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
name | query | string | Yes | The file's name, as the team will see it. |
Request body
application/octet-stream, required.
Responses
| Status | Description |
|---|---|
200 | The stored file. |
400 | invalid_request: the name query parameter is missing. empty_file: the body is empty. file_too_big: the file is over 20 MB. |
401 | missing_api_key: no bearer token. invalid_api_key: the key matches no organization or was revoked. publishable_key: a median_pk_ key was sent. An OAuth access token is refused here with invalid_api_key. |
429 | The organization's API allowance for this class of request is used up. Wait the Retry-After header's seconds. Limits depend on the plan. See rate limits. |
200 body
| Field | Type | Required | Description |
|---|---|---|---|
attachmentId | string | Yes | |
name | string | Yes | |
size | integer | Yes | |
type | string | Yes |
Example response
{
"attachmentId": "kg2f...",
"name": "receipt.pdf",
"size": 182044,
"type": "application/pdf"
}Example request
curl -X POST https://api.median.sh/v1/uploads?name=receipt.pdf \
-H "Authorization: Bearer $MEDIAN_KEY"