You can create posts with text attachments using the Threads API. Text attachments allow you to share long-form writing in a post or a reply with up to 10,000 characters and a link. They can also include emojis and style formatting.
You can add a text attachment to a post by making a request to the POST /{threads-user-id}/threads endpoint to create a media container with the text_attachment JSON object.
| Name | Description |
|---|---|
string | Required. |
URL | Optional. |
string | Optional. Values: Note: The text styling info ranges within the Available text styles:
|
curl -i -X POST \
-d "media_type=TEXT" \
-d "text=<TEXT>" \
-d "access_token=<ACCESS_TOKEN>" \
-d "text_attachment=
{
"plaintext": "Lengthy plain text for the text attachment.",
"link_attachment_url": "<LINK_URL>",
"text_with_styling_info":[
{
"offset": 0,
"length": 7,
"styling_info":["bold","italic"]
},
{
"offset": 7,
"length": 10,
"styling_info":["highlight"]
}]
}" \
"https://graph.threads.net/v1.0/<THREADS_USER_ID>/threads"
{
"id": "<THREADS_MEDIA_CONTAINER_ID>"
}
You can publish using the returned Threads media container ID to create your Threads post with a text attachment.
Make a request to the GET /{threads-user-id}/threads or GET /{threads-media-id} endpoint with the text_attachment field to retrieve any media object(s) with text attachments.
| Name | Description |
|---|---|
| The text attachment for the post. |
curl -i -X GET \ -d "access_token=<ACCESS_TOKEN>" \ -d "fields=id,text_attachment" \ "https://graph.threads.net/v1.0/<THREADS_MEDIA_ID>
{
"id": "<THREADS_MEDIA_ID>",
"text_attachment": {
"plaintext": "Lengthy plaintext for the text attachment.",
"link_attachment_url": "<LINK_URL>",
"text_with_styling_info": [
{
"offset": 0,
"length": 7,
"styling_info":["bold","italic"]
},
{
"offset": 7,
"length": 10,
"styling_info":["highlight"]
}]
}
}