2020-07-30 12:09:33 +00:00
---
stage: Create
group: Knowledge
2020-11-26 06:09:20 +00:00
info: "To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments"
2020-07-30 12:09:33 +00:00
type: reference, api
---
2020-10-16 15:08:46 +00:00
# Project wikis API
2017-09-06 22:21:52 +00:00
2020-04-21 15:21:10 +00:00
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/13372) in GitLab 10.0.
2017-09-06 22:21:52 +00:00
Available only in APIv4.
## List wiki pages
Get all wiki pages for a given project.
2020-02-29 03:07:51 +00:00
```plaintext
2017-09-06 22:21:52 +00:00
GET /projects/:id/wikis
```
| Attribute | Type | Required | Description |
| --------- | ------- | -------- | --------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) |
| `with_content` | boolean | no | Include pages' content |
2020-01-30 15:09:15 +00:00
```shell
2020-05-28 00:08:37 +00:00
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/wikis?with_content=1"
2017-09-06 22:21:52 +00:00
```
Example response:
```json
[
{
"content" : "Here is an instruction how to deploy this project.",
"format" : "markdown",
"slug" : "deploy",
"title" : "deploy"
},
{
"content" : "Our development process is described here.",
"format" : "markdown",
"slug" : "development",
"title" : "development"
},{
"content" : "* [Deploy ](deploy )\n* [Development ](development )",
"format" : "markdown",
"slug" : "home",
"title" : "home"
}
]
```
## Get a wiki page
Get a wiki page for a given project.
2020-02-29 03:07:51 +00:00
```plaintext
2017-09-06 22:21:52 +00:00
GET /projects/:id/wikis/:slug
```
| Attribute | Type | Required | Description |
| --------- | ------- | -------- | --------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) |
| `slug` | string | yes | The slug (a unique string) of the wiki page |
2020-01-30 15:09:15 +00:00
```shell
2020-05-28 00:08:37 +00:00
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/wikis/home"
2017-09-06 22:21:52 +00:00
```
Example response:
```json
2018-11-21 07:33:49 +00:00
{
"content" : "home page",
"format" : "markdown",
"slug" : "home",
"title" : "home"
}
2017-09-06 22:21:52 +00:00
```
## Create a new wiki page
Creates a new wiki page for the given repository with the given title, slug, and content.
2020-02-29 03:07:51 +00:00
```plaintext
2017-09-06 22:21:52 +00:00
POST /projects/:id/wikis
```
| Attribute | Type | Required | Description |
| ------------- | ------- | -------- | ---------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) |
| `content` | string | yes | The content of the wiki page |
| `title` | string | yes | The title of the wiki page |
2020-01-16 03:08:47 +00:00
| `format` | string | no | The format of the wiki page. Available formats are: `markdown` (default), `rdoc` , `asciidoc` and `org` |
2017-09-06 22:21:52 +00:00
2020-01-30 15:09:15 +00:00
```shell
2018-12-27 09:03:08 +00:00
curl --data "format=rdoc& title=Hello& content=Hello world" --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/wikis"
2017-09-06 22:21:52 +00:00
```
Example response:
```json
2018-09-04 10:39:08 +00:00
{
2017-09-06 22:21:52 +00:00
"content" : "Hello world",
"format" : "markdown",
"slug" : "Hello",
"title" : "Hello"
2018-09-04 10:39:08 +00:00
}
2017-09-06 22:21:52 +00:00
```
## Edit an existing wiki page
Updates an existing wiki page. At least one parameter is required to update the wiki page.
2020-02-29 03:07:51 +00:00
```plaintext
2017-09-06 22:21:52 +00:00
PUT /projects/:id/wikis/:slug
```
| Attribute | Type | Required | Description |
| --------------- | ------- | --------------------------------- | ------------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) |
| `content` | string | yes if `title` is not provided | The content of the wiki page |
| `title` | string | yes if `content` is not provided | The title of the wiki page |
2020-01-16 03:08:47 +00:00
| `format` | string | no | The format of the wiki page. Available formats are: `markdown` (default), `rdoc` , `asciidoc` and `org` |
2017-09-06 22:21:52 +00:00
| `slug` | string | yes | The slug (a unique string) of the wiki page |
2020-01-30 15:09:15 +00:00
```shell
2018-12-27 09:03:08 +00:00
curl --request PUT --data "format=rdoc& content=documentation& title=Docs" --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/wikis/foo"
2017-09-06 22:21:52 +00:00
```
Example response:
```json
{
"content" : "documentation",
"format" : "markdown",
"slug" : "Docs",
"title" : "Docs"
}
```
## Delete a wiki page
Deletes a wiki page with a given slug.
2020-02-29 03:07:51 +00:00
```plaintext
2017-09-06 22:21:52 +00:00
DELETE /projects/:id/wikis/:slug
```
| Attribute | Type | Required | Description |
| --------- | ------- | -------- | --------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) |
| `slug` | string | yes | The slug (a unique string) of the wiki page |
2020-01-30 15:09:15 +00:00
```shell
2018-12-27 09:03:08 +00:00
curl --request DELETE --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/wikis/foo"
2017-09-06 22:21:52 +00:00
```
2018-09-04 10:39:08 +00:00
On success the HTTP status code is `204` and no JSON response is expected.
2017-09-15 11:27:57 +00:00
2018-09-04 10:39:08 +00:00
## Upload an attachment to the wiki repository
Uploads a file to the attachment folder inside the wiki's repository. The
attachment folder is the `uploads` folder.
2020-02-29 03:07:51 +00:00
```plaintext
2018-09-04 10:39:08 +00:00
POST /projects/:id/wikis/attachments
```
| Attribute | Type | Required | Description |
| ------------- | ------- | -------- | ---------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) |
| `file` | string | yes | The attachment to be uploaded |
| `branch` | string | no | The name of the branch. Defaults to the wiki repository default branch |
To upload a file from your filesystem, use the `--form` argument. This causes
cURL to post data using the header `Content-Type: multipart/form-data` .
The `file=` parameter must point to a file on your filesystem and be preceded
by `@` . For example:
2020-01-30 15:09:15 +00:00
```shell
2020-05-28 00:08:37 +00:00
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " --form "file=@dk.png" "https://gitlab.example.com/api/v4/projects/1/wikis/attachments"
2018-09-04 10:39:08 +00:00
```
Example response:
```json
{
"file_name" : "dk.png",
"file_path" : "uploads/6a061c4cf9f1c28cb22c384b4b8d4e3c/dk.png",
"branch" : "master",
"link" : {
"url" : "uploads/6a061c4cf9f1c28cb22c384b4b8d4e3c/dk.png",
"markdown" : "![dk](uploads/6a061c4cf9f1c28cb22c384b4b8d4e3c/dk.png)"
}
}
```