POST/gists

Create a gist

Creates a new gist containing one or more files. Supply file names and their content in files; public defaults to false when omitted. Avoid names that match Gist’s automatic gistfile numbering pattern.

  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

3 body fields

Gist details, including the required file map and optional description and visibility setting.

descriptionstringoptional
Description of the gist
filesobjectrequired
Names and content for the files that make up the gist
publicbooleanoptional
Whether the gist is public. Accepts a boolean or the string `true` or `false`; defaults to false when omitted.
Default:false

5 status codes
201Returns the created gist object, including its identifier, file details, visibility, and URLs.
forksarray<object>deprecatedoptional
historyarray<GistHistory>deprecatedoptional
fork_ofobjectoptional
Gist
urlstringoptional
forks_urlstringoptional
commits_urlstringoptional
idstringoptional
node_idstringoptional
git_pull_urlstringoptional
git_push_urlstringoptional
html_urlstringoptional
filesobjectoptional
publicbooleanoptional
created_atstringoptional
updated_atstringoptional
descriptionstringoptional
commentsintegeroptional
comments_enabledbooleanoptional
userstringoptional
comments_urlstringoptional
ownerobjectoptional
A GitHub user.
truncatedbooleanoptional
304Returned when the resource has not been modified.
403Returned when the request is forbidden.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
404Returned when the requested resource cannot be found.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
422Returned when validation fails or the endpoint has been spammed.
messagestringrequired
documentation_urlstringrequired
errorsarray<object>optional

Error handling

A 403 is returned when the request is forbidden. A 404 is returned when a requested resource cannot be found. A 422 is returned when validation fails or the endpoint has been spammed. The files field is required, and each file entry must include content; public accepts a boolean or the string true or false.