POST/repos/{owner}/{repo}/git/blobs

Create a Git blob

Creates a Git blob in a repository from the supplied content. Provide content and, if needed, set encoding to control how the content is decoded; the default encoding is UTF-8. A 201 response returns the blob's URL and SHA.

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

2 parameters · 2 body fields
ownerstringrequired
The account owner of the repository.
repostringrequired
The repository name without the `.git` extension.

Git blob content and its encoding.

contentstringrequired
The new blob's content.
encodingstringoptional
The encoding used for `content`. Currently, `"utf-8"` and `"base64"` are supported.
Default:utf-8

5 status codes
201Returns the created blob's URL and SHA.
urlstringrequired
shastringrequired
403Returned when you do not have permission to create a blob in the repository.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
404Returned when the repository cannot be found.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
409Returned when the request conflicts with the repository's current state.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
422Returned when validation fails.
messagestringrequired
documentation_urlstringrequired
errorsarray<object>optional

Error handling

A 403 is returned when you do not have permission to create blobs in the repository. A 404 is returned when the repository identified by the owner path parameter and repo path parameter cannot be found. A 409 indicates a conflict, and a 422 is returned when validation fails; content is required and encoding must be utf-8 or base64 when provided.