Median

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

NameInTypeRequiredDescription
namequerystringYesThe file's name, as the team will see it.

Request body

application/octet-stream, required.

Responses

StatusDescription
200The stored file.
400invalid_request: the name query parameter is missing. empty_file: the body is empty. file_too_big: the file is over 20 MB.
401missing_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.
429The 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

FieldTypeRequiredDescription
attachmentIdstringYes
namestringYes
sizeintegerYes
typestringYes

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"

Still need help?

    Esc