Article Attachments
JSON Format
Article attachments have the following keys:
Name | Type | Comment |
---|---|---|
id | integer | Automatically assigned when the article attachment is created |
url | string | The API url of this article attachment |
article_id | integer | Id of the associated article, if present |
file_name | string | The name of the file |
content_url | string | A full URL where the attachment file can be downloaded |
content_type | string | The content type of the file. Example: image/png |
size | integer | The size of the attachment file in bytes |
inline | boolean | If true, the attached file is shown in the dedicated admin UI for inline attachments and its url can be referenced in the HTML body of the article. If false, the attachment is listed in the list of attachments. Default is false |
created_at | timestamp | The time at which the article attachment was created |
updated_at | timestamp | The time at which the article attachment was last updated |
Example
{
"id": 1428,
"article_id": 23,
"file_name": "party_invitation.pdf",
"content_url": "https://company.zendesk.com/hc/article_attachments/200109629/party_invitation.pdf",
"content_type": "application/pdf",
"size": 58298,
"inline": false,
"created_at": "2012-04-04T09:14:57Z",
...
}
List Article Attachments
GET /api/v2/help_center/{locale}/articles/{article_id}/attachments.json
Lists all the article's attachments.
The {locale}
is required only for end users. Admins and agents can omit it.
Allowed for
- Agents
- End users, as long as they can view the associated article
Using curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/{locale}/articles/{article_id}/attachments.json \
-v -u {email_address}:{password}
Example Response
Status: 200 OK
{
"article_attachments": [
{
"id": 1428,
"article_id": 23,
"file_name": "logo.jpg",
"content_url": "https://company.zendesk.com/hc/article_attachments/200109629/logo.jpg",
"content_type": "application/jpeg",
"size": 1428,
"inline": true
},
{
"id": 2857,
"article_id": 23,
"file_name": "party_invitation.pdf",
"content_url": "https://company.zendesk.com/hc/article_attachments/200109629/party_invitation.pdf",
"content_type": "application/pdf",
"size": 58298,
"inline": false
},
...
]
}
List Article Inline Attachments
GET /api/v2/help_center/{locale}/articles/{article_id}/attachments/inline.json
Lists all the article's inline attachments.
The {locale}
is required only for end users. Admins and agents can omit it.
Allowed for
- Agents
- End users, as long as they can view the associated article
Using curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/{locale}/articles/{article_id}/attachments/inline.json \
-v -u {email_address}:{password}
Example Response
Status: 200 OK
{
"article_attachments": [
{
"id": 1428,
"article_id": 23,
"file_name": "logo.jpg",
"content_url": "https://company.zendesk.com/hc/article_attachments/200109629/logo.jpg",
"content_type": "application/jpeg",
"size": 1428,
"inline": true
},
{
"id": 2857,
"article_id": 23,
"file_name": "footer.gif",
"content_url": "https://company.zendesk.com/hc/article_attachments/200109629/footer.gif",
"content_type": "application/gif",
"size": 234,
"inline": true
},
...
]
}
List Article Block Attachments
GET /api/v2/help_center/{locale}/articles/{article_id}/attachments/block.json
Lists all the article's block attachments. Block attachments are those that are not inline.
The {locale}
is required only for end users. Admins and agents can omit it.
Allowed for
- Agents
- End users, as long as they can view the associated article
Using curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/{locale}/articles/{article_id}/attachments/block.json \
-v -u {email_address}:{password}
Example Response
Status: 200 OK
{
"article_attachments": [
{
"id": 1428,
"article_id": 23,
"file_name": "logo.pdf",
"content_url": "https://company.zendesk.com/hc/article_attachments/200109629/logo.pdf",
"content_type": "application/pdf",
"size": 1428,
"inline": false
},
{
"id": 2857,
"article_id": 23,
"file_name": "results.doc",
"content_url": "https://company.zendesk.com/hc/article_attachments/200109629/results.doc",
"content_type": "application/msword",
"size": 234,
"inline": false
},
...
]
}
Show Article Attachment
GET /api/v2/help_center/{locale}/articles/attachments/{id}.json
Shows the properties of the specified attachment.
The {locale}
is required only for end users. Admins and agents can omit it.
Allowed for
- Agents
- End users, as long as they can view the associated article
Using curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/{locale}/articles/attachments/{id}.json \
-v -u {email_address}:{password}
Example Response
Status: 200 OK
{
"article_attachment": {
"id": 1428,
"article_id": 23,
"file_name": "logo.jpg",
"content_url": "https://company.zendesk.com/hc/article_attachments/200109629/logo.jpg",
"content_type": "application/jpeg",
"size": 1428,
"inline": true,
...
}
}
Create Article Attachment
POST /api/v2/help_center/articles/{article_id}/attachments.json
Creates an attachment for the specified article. You can specify whether the
attachment is inline
or not. The default is false
.
Allowed for
- Agents
Using curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/articles/{id}/attachments.json \
-F "inline=true" -F "file=@drawing.png" \
-v -u {email_address}:{password} -X POST
Example Response
Status: 201 Created
Location: https://{subdomain}.zendesk.com/api/v2/help_center/articles/{id}/attachments.json
{
"article_attachment": {
"id": 1428,
"article_id": 23,
"file_name": "drawing.png",
"content_url": "https://company.zendesk.com/hc/article_attachments/200109629/drawing.png",
"content_type": "image/png",
"size": 58298,
"inline": true
}
}
Create Unassociated Attachment
POST /api/v2/help_center/articles/attachments.json
You can use this endpoint for bulk imports. It lets you upload a file without associating it to an article until later. See Associate Attachments in Bulk to Article.
Note: Associate attachments to articles as soon as possible. For example, if you use the endpoint to bulk-import inline images, only signed-in end users can see the images; anonymous users don't have permission to view unassociated images. Also, from time to time, we purge old article attachments not associated to any article. To ensure you don't lose an uploaded file, associate it to an article.
Allowed for
- Agents
Using curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/articles/attachments.json \
-F "inline=true" -F "file=@logo.jpg" \
-v -u {email_address}:{password} -X POST
Example Response
Status: 201 Created
Location: https://{subdomain}.zendesk.com/api/v2/help_center/articles/attachments.json
{
"article_attachment": {
"id": 1428,
"article_id": null,
"file_name": "party_invitation.pdf",
"content_url": "https://company.zendesk.com/hc/article_attachments/1428/party_invitation.pdf",
"content_type": "application/pdf",
"size": 58298,
"inline": false
}
}
Delete Article Attachment
DELETE /api/v2/help_center/articles/attachments/{id}.json
Allowed for
- Agents
Using curl
curl https://{subdomain}.zendesk.com/api/v2/help_center/articles/attachments/{id}.json \
-v -u {email_address}:{password} -X DELETE
Example Response
Status: 204 No Content