Add a public key on behalf of a user
const url = 'https://gitea.example.com/api/v1/admin/users/example/keys';const options = { method: 'POST', headers: {Authorization: 'Basic <credentials>', 'Content-Type': 'application/json'}, body: '{"key":"example","read_only":true,"title":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://gitea.example.com/api/v1/admin/users/example/keys \ --header 'Authorization: Basic <credentials>' \ --header 'Content-Type: application/json' \ --data '{ "key": "example", "read_only": true, "title": "example" }'Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Username of the user
Request Body
Section titled “Request Body”CreateKeyOption options when creating a key
object
An armored SSH key to add
Describe if the key has only read access or read/write
Title of the key to add
Examplegenerated
{ "key": "example", "read_only": true, "title": "example"}Responses
Section titled “Responses”PublicKey
PublicKey publickey is a user key to push code to repository
object
User represents a user
object
Is user active
URL to the user’s avatar
The user’s description
User counts
The user’s full name
URL to the user’s gitea page
The user’s id
Is the user an administrator
User locale
The user’s location
The user’s username
The user’s authentication sign-in name.
Is user login prohibited
Is user restricted
The ID of the user’s Authentication Source
User visibility level option: public, limited, private
The user’s website
Example
{ "user": { "login_name": "empty" }}APIForbiddenError is a forbidden error response
Headers
Section titled “Headers”APIValidationError is error format response related to input validation