Create a tag protections for a repository
POST
/repos/{owner}/{repo}/tag_protections
const url = 'https://gitea.com/api/v1/repos/example/example/tag_protections';const options = { method: 'POST', headers: {Authorization: 'Basic <credentials>', 'Content-Type': 'application/json'}, body: '{"name_pattern":"example","whitelist_teams":["example"],"whitelist_usernames":["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/repos/example/example/tag_protections \ --header 'Authorization: Basic <credentials>' \ --header 'Content-Type: application/json' \ --data '{ "name_pattern": "example", "whitelist_teams": [ "example" ], "whitelist_usernames": [ "example" ] }'Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”owner
required
string
Owner of the repo
repo
required
string
Name of the repo
Request Body
Section titled “Request Body”Media typeapplication/json
CreateTagProtectionOption options for creating a tag protection
object
name_pattern
string
whitelist_teams
Array<string>
whitelist_usernames
Array<string>
Examplegenerated
{ "name_pattern": "example", "whitelist_teams": [ "example" ], "whitelist_usernames": [ "example" ]}Responses
Section titled “Responses”TagProtection
Media typeapplication/json
TagProtection represents a tag protection
object
created_at
string format: date-time
id
integer format: int64
name_pattern
string
updated_at
string format: date-time
whitelist_teams
Array<string>
whitelist_usernames
Array<string>
Examplegenerated
{ "created_at": "2026-04-15T12:00:00Z", "id": 1, "name_pattern": "example", "updated_at": "2026-04-15T12:00:00Z", "whitelist_teams": [ "example" ], "whitelist_usernames": [ "example" ]}APIForbiddenError is a forbidden error response
Media typeapplication/json
Headers
Section titled “Headers”message
string
url
string
APINotFound is a not found empty response
Media typeapplication/json
APIValidationError is error format response related to input validation
Media typeapplication/json
Headers
Section titled “Headers”message
string
url
string
APIRepoArchivedError is an error that is raised when an archived repo should be modified
Media typeapplication/json
Headers
Section titled “Headers”message
string
url
string