Sample - GitHub REST API
POST/gists

Create a gist

Creates a new gist containing one or more files. Supply files with each filename and its content, and use public to control visibility; avoid filenames that match Gist's internal gistfile numbering scheme.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

3 body fields

Gist creation details, including the files, optional description, and visibility setting.

descriptionstringoptional
Description of the gist
filesobjectrequired
Names and content for the files that make up the gist
publicbooleanoptional
Controls whether the gist is public, as a boolean or the string `true` or `false`. Defaults to false when omitted.
Default:false

5 status codes
201Returns the created gist, including its identifiers, URLs, visibility, timestamps, and file information.
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 gist has not changed since the caller's cached version.
403Returned when the authenticated user is not permitted to create the gist.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
404Returned when the requested resource cannot be found.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
422Returned when gist validation fails or the endpoint has been spammed.
messagestringrequired
documentation_urlstringrequired
errorsarray<object>optional

Error handling

A 403 is returned when the authenticated user is not permitted to create the gist, and a 404 is returned when the referenced resource cannot be found. A 422 is returned when validation fails or the endpoint has been spammed; files must be provided with content for each file, and public must be a boolean or true/false string.