Attach a picture, video or PDF
upload_mediaAttach an image, video or PDF and get a media_id for create_post. Sources: file (an attachment from this conversation, as the host provides it), a public https url, base64 data with mime_type. Instagram, TikTok, YouTube and Pinterest need media; a PDF becomes a LinkedIn document post. When an attached file cannot be provided from here, create the post with media_pending: true instead and the person adds it in the approval card. Formats and caps: https://xpost.to/docs/api#media.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | No | Public https URL | |
| data | No | The bytes of a small image, video or PDF generated here, base64-encoded, with `mime_type`. A file the user attached travels as `file`, or through the post's `upload_url`, not here. | |
| file | No | A file the user attached to this conversation, as the host hands it over. Absent when the host has no such object. | |
| alt_text | No | Images: accessibility alt text (max 1000 chars). Applied natively on X and Bluesky | |
| mime_type | No | MIME type for `data`, e.g. image/png, video/mp4 | |
| thumbnail_timestamp_ms | No | Videos: cover-frame time in ms into the video |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | Pass in create_post's media_ids. | |
| ok | No | Present and false only on a refusal. | |
| kind | No | ||
| error | No | What was refused, in a sentence, when `ok` is false. | |
| retriable | No | False when asking again cannot change the answer. | |
| error_code | No | Machine reason for a refusal. | |
| people_tags | No | ||
| replaced_by | No | The id the post has now, when you asked with one an edit retired. An edit gives a post a new id: get_delivery_receipt and get_post_metrics answer for this current version (and `asked_for` is the id you sent); update_post and delete_post refuse with error_code `replaced`. Use this id from here on. |