Skip to content
Try Gitea Cloud ☁️ for 30 days → Accelerate your Development & Deploys!

Create a public key

POST
/user/keys
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" }'
Media typeapplication/json

CreateKeyOption options when creating a key

object
key
required

An armored SSH key to add

string
unique items
read_only

Describe if the key has only read access or read/write

boolean
title
required

Title of the key to add

string
unique items
Examplegenerated
{
"key": "example",
"read_only": true,
"title": "example"
}

PublicKey

Media typeapplication/json

PublicKey publickey is a user key to push code to repository

object
created_at
string format: date-time
fingerprint

Fingerprint is the key’s fingerprint

string
id

ID is the unique identifier for the public key

integer format: int64
key

Key contains the actual SSH public key content

string
key_type

KeyType indicates the type of the SSH key

string
last_used_at

Updated is the time when the key was last used

string format: date-time
read_only

ReadOnly indicates if the key has read-only access

boolean
title

Title is the human-readable name for the key

string
url

URL is the API URL for this key

string format: uri
user

User represents a user

object
active

Is user active

boolean
avatar_url

URL to the user’s avatar

string format: uri
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 format: uri
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

Login of the user, same as username

string
login_name

Identifier of the user, provided by the external authenticator (if configured)

string
default: empty
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 public UserVisibilityPublic limited UserVisibilityLimited private UserVisibilityPrivate

string
Allowed values: public limited private
website

The user’s website

string
Example
{
"user": {
"login_name": "empty",
"visibility": "public"
}
}

APIValidationError is error format response related to input validation

message
string
url
string