Create a public key
POST
/user/keys
const url = 'https://gitea.com/api/v1/user/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.com/api/v1/user/keys \ --header 'Authorization: Basic <credentials>' \ --header 'Content-Type: application/json' \ --data '{ "key": "example", "read_only": true, "title": "example" }'Authorizations
Section titled “Authorizations”Request Body
Section titled “Request Body”Media typeapplication/json
CreateKeyOption options when creating a key
object
key
required
An armored SSH key to add
string
read_only
Describe if the key has only read access or read/write
boolean
title
required
Title of the key to add
string
Examplegenerated
{ "key": "example", "read_only": true, "title": "example"}Responses
Section titled “Responses”PublicKey
Media typeapplication/json
PublicKey publickey is a user key to push code to repository
object
created_at
string format: date-time
fingerprint
string
id
integer format: int64
key
string
key_type
string
last_used_at
string format: date-time
read_only
boolean
title
string
url
string
user
User represents a user
object
active
Is user active
boolean
avatar_url
URL to the user’s avatar
string
created
string format: date-time
description
The user’s description
string
email
string format: email
followers_count
User counts
integer format: int64
following_count
integer format: int64
full_name
The user’s full name
string
html_url
URL to the user’s gitea page
string
id
The user’s id
integer format: int64
is_admin
Is the user an administrator
boolean
language
User locale
string
last_login
string format: date-time
location
The user’s location
string
login
The user’s username
string
login_name
The user’s authentication sign-in name.
string
prohibit_login
Is user login prohibited
boolean
restricted
Is user restricted
boolean
source_id
The ID of the user’s Authentication Source
integer format: int64
starred_repos_count
integer format: int64
visibility
User visibility level option: public, limited, private
string
website
The user’s website
string
Example
{ "user": { "login_name": "empty" }}APIValidationError is error format response related to input validation
Media typeapplication/json
Headers
Section titled “Headers”message
string
url
string