Skip to content

Update snippet

PUT
/api/v4/snippets/{id}

Updates a specified snippet.

id
required
integer

The ID of a snippet

Media type application/json
object
content

The content of a snippet

string
nullable
description

The description of a snippet

string
nullable
file_name

The name of a snippet file

string
nullable
title

The title of a snippet

string
nullable
visibility

The visibility of the snippet

string
nullable
Allowed values: private internal public
files

An array of files to update

Array<object>
nullable
object
action
required

The type of action to perform on the file, must be one of: create, update, delete, move

string
>= 1 characters
Allowed values: create update delete move
content

The content of a snippet

string
nullable
file_path

The file path of a snippet file

string
nullable
previous_path

The previous path of a snippet file

string
nullable

OK

Media type application/json
object
id
integer format: int64
title
string
description
string
visibility
string
author
object
id
integer format: int64
username
string
public_email
string
name
string
state
string
locked
boolean
avatar_url
string
avatar_path
string
custom_attributes
Array<object>
object
key
string
value
string
web_url
string
created_at
string format: date-time
updated_at
string format: date-time
project_id
integer format: int64
web_url
string
raw_url
string
ssh_url_to_repo
string
http_url_to_repo
string
file_name
string
files
Array<object>
object
imported
boolean
imported_from
string
repository_storage
string
Example
{
"id": 1,
"title": "test",
"description": "Ruby test snippet",
"visibility": "public",
"author": {
"id": 1,
"username": "admin",
"public_email": "john@example.com",
"name": "Administrator",
"state": "active",
"avatar_url": "https://gravatar.com/avatar/1",
"avatar_path": "/user/avatar/28/The-Big-Lebowski-400-400.png",
"custom_attributes": [
{
"key": "foo",
"value": "bar"
}
],
"web_url": "https://gitlab.example.com/root"
},
"created_at": "2012-06-28T10:52:04Z",
"updated_at": "2012-06-28T10:52:04Z",
"project_id": 1,
"web_url": "http://example.com/example/example/snippets/1",
"raw_url": "http://example.com/example/example/snippets/1/raw",
"ssh_url_to_repo": "ssh://user@gitlab.example.com/snippets/65.git",
"http_url_to_repo": "https://gitlab.example.com/snippets/65.git",
"file_name": "add.rb",
"files": [
{
"path": "file.txt",
"raw_url": "https://gitlab.example.com/.../raw"
}
],
"imported": false,
"imported_from": "none",
"repository_storage": "default"
}

Validation error

Not found

Unprocessable entity