Skip to main content

Create a content attachment

Creates an attachment under a content reference URL in the body or comment of an issue or pull request. Use the `id` and `repository` `full_name` of the content reference from the [`content_reference` event](https://docs.github.com/[email protected]/webhooks/event-payloads/#content_reference) to create an attachment. The app must create a content attachment within six hours of the content reference URL being posted. See "[Using content attachments](https://docs.github.com/[email protected]/apps/using-content-attachments/)" for details about content attachments. You must use an [installation access token](https://docs.github.com/[email protected]/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-an-installation) to access this endpoint.

POST/repos/{owner}/{repo}/content_references/{content_reference_id}/attachments
Source
github-v3-rest.json
Revision
f5f067c1e6f6
Active snapshot
85e53e3d0d65

Request

Path Parameters
owner string
required

The owner of the repository. Determined from the `repository` `full_name` of the `content_reference` event.

repo string
required

The name of the repository. Determined from the `repository` `full_name` of the `content_reference` event.

content_reference_id integer
required

The `id` of the `content_reference` event.

Body Params
required
application/jsonobject
body string
required

The body of the attachment

Example: Body of the attachment

title string
required

The title of the attachment

Example: Title of the attachment

Responses

application/json ContentReferenceAttachment object

Response

body string
required

The body of the attachment

Example: Body of the attachment

id integer
required

The ID of the attachment

Example: 21

node_id string
optional

The node_id of the content attachment

Example: MDE3OkNvbnRlbnRBdHRhY2htZW50MjE=

title string
required

The title of the attachment

Example: Title of the attachment

Not modified

application/json Basic Error object

Forbidden

documentation_url string
optional
message string
optional
status string
optional
url string
optional
application/json Basic Error object

Resource not found

documentation_url string
optional
message string
optional
status string
optional
url string
optional
application/json Basic Error object

Gone

documentation_url string
optional
message string
optional
status string
optional
url string
optional
application/json object

Preview header missing

documentation_url string
required
message string
required
application/json Validation Error object

Validation failed

documentation_url string
required
errors array[object]
optional
items object
code string
required
field string
optional
index integer
optional
message string
optional
resource string
optional
value
optional
message string
required