2020-10-24 23:57:45 +05:30
---
stage: Create
2021-03-11 19:13:27 +05:30
group: Editor
2022-03-02 08:16:31 +05:30
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-10-24 23:57:45 +05:30
---
2021-04-17 20:07:23 +05:30
# Project wikis API **(FREE)**
2018-03-17 18:26:18 +05:30
2021-04-29 21:17:54 +05:30
The project [wikis ](../user/project/wiki/index.md ) API is available only in APIv4.
An API for [group wikis ](group_wikis.md ) is also available.
2018-03-17 18:26:18 +05:30
## List wiki pages
Get all wiki pages for a given project.
2020-04-08 14:13:33 +05:30
```plaintext
2018-03-17 18:26:18 +05:30
GET /projects/:id/wikis
```
| Attribute | Type | Required | Description |
| --------- | ------- | -------- | --------------------- |
2021-09-30 23:02:18 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) |
2018-03-17 18:26:18 +05:30
| `with_content` | boolean | no | Include pages' content |
2020-03-13 15:44:24 +05:30
```shell
2020-06-23 00:09:42 +05:30
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/wikis?with_content=1"
2018-03-17 18:26:18 +05:30
```
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-04-08 14:13:33 +05:30
```plaintext
2018-03-17 18:26:18 +05:30
GET /projects/:id/wikis/:slug
```
| Attribute | Type | Required | Description |
| --------- | ------- | -------- | --------------------- |
2021-09-30 23:02:18 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) |
2021-09-04 01:27:46 +05:30
| `slug` | string | yes | URLencoded slug (a unique string) of the wiki page, such as `dir%2Fpage_name` |
2018-03-17 18:26:18 +05:30
2020-03-13 15:44:24 +05:30
```shell
2020-06-23 00:09:42 +05:30
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/wikis/home"
2018-03-17 18:26:18 +05:30
```
Example response:
```json
2019-02-15 15:39:39 +05:30
{
"content" : "home page",
"format" : "markdown",
"slug" : "home",
"title" : "home"
}
2018-03-17 18:26:18 +05:30
```
## Create a new wiki page
Creates a new wiki page for the given repository with the given title, slug, and content.
2020-04-08 14:13:33 +05:30
```plaintext
2018-03-17 18:26:18 +05:30
POST /projects/:id/wikis
```
| Attribute | Type | Required | Description |
| ------------- | ------- | -------- | ---------------------------- |
2021-09-30 23:02:18 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) |
2018-03-17 18:26:18 +05:30
| `content` | string | yes | The content of the wiki page |
| `title` | string | yes | The title of the wiki page |
2020-03-13 15:44:24 +05:30
| `format` | string | no | The format of the wiki page. Available formats are: `markdown` (default), `rdoc` , `asciidoc` and `org` |
2018-03-17 18:26:18 +05:30
2020-03-13 15:44:24 +05:30
```shell
2021-09-04 01:27:46 +05:30
curl --data "format=rdoc& title=Hello& content=Hello world" \
--header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/wikis"
2018-03-17 18:26:18 +05:30
```
Example response:
```json
2018-11-20 20:47:30 +05:30
{
2018-03-17 18:26:18 +05:30
"content" : "Hello world",
"format" : "markdown",
"slug" : "Hello",
"title" : "Hello"
2018-11-20 20:47:30 +05:30
}
2018-03-17 18:26:18 +05:30
```
## Edit an existing wiki page
Updates an existing wiki page. At least one parameter is required to update the wiki page.
2020-04-08 14:13:33 +05:30
```plaintext
2018-03-17 18:26:18 +05:30
PUT /projects/:id/wikis/:slug
```
| Attribute | Type | Required | Description |
| --------------- | ------- | --------------------------------- | ------------------------------- |
2021-09-30 23:02:18 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) |
2018-03-17 18:26:18 +05:30
| `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-03-13 15:44:24 +05:30
| `format` | string | no | The format of the wiki page. Available formats are: `markdown` (default), `rdoc` , `asciidoc` and `org` |
2021-09-04 01:27:46 +05:30
| `slug` | string | yes | URL-encoded slug (a unique string) of the wiki page, such as `dir%2Fpage_name` |
2018-03-17 18:26:18 +05:30
2020-03-13 15:44:24 +05:30
```shell
2021-09-04 01:27:46 +05:30
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"
2018-03-17 18:26:18 +05:30
```
Example response:
```json
{
"content" : "documentation",
"format" : "markdown",
"slug" : "Docs",
"title" : "Docs"
}
```
## Delete a wiki page
Deletes a wiki page with a given slug.
2020-04-08 14:13:33 +05:30
```plaintext
2018-03-17 18:26:18 +05:30
DELETE /projects/:id/wikis/:slug
```
| Attribute | Type | Required | Description |
| --------- | ------- | -------- | --------------------- |
2021-09-30 23:02:18 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) |
2021-09-04 01:27:46 +05:30
| `slug` | string | yes | URL-encoded slug (a unique string) of the wiki page, such as `dir%2Fpage_name` |
2018-03-17 18:26:18 +05:30
2020-03-13 15:44:24 +05:30
```shell
2019-02-15 15:39:39 +05:30
curl --request DELETE --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/wikis/foo"
2018-03-17 18:26:18 +05:30
```
2018-11-20 20:47:30 +05:30
On success the HTTP status code is `204` and no JSON response is expected.
2018-03-17 18:26:18 +05:30
2018-11-20 20:47:30 +05:30
## 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-04-08 14:13:33 +05:30
```plaintext
2018-11-20 20:47:30 +05:30
POST /projects/:id/wikis/attachments
```
| Attribute | Type | Required | Description |
| ------------- | ------- | -------- | ---------------------------- |
2021-09-30 23:02:18 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) |
2018-11-20 20:47:30 +05:30
| `file` | string | yes | The attachment to be uploaded |
| `branch` | string | no | The name of the branch. Defaults to the wiki repository default branch |
2021-03-11 19:13:27 +05:30
To upload a file from your file system, use the `--form` argument. This causes
2018-11-20 20:47:30 +05:30
cURL to post data using the header `Content-Type: multipart/form-data` .
2021-03-11 19:13:27 +05:30
The `file=` parameter must point to a file on your file system and be preceded
2018-11-20 20:47:30 +05:30
by `@` . For example:
2020-03-13 15:44:24 +05:30
```shell
2021-09-04 01:27:46 +05:30
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " \
--form "file=@dk.png" "https://gitlab.example.com/api/v4/projects/1/wikis/attachments"
2018-11-20 20:47:30 +05:30
```
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)"
}
}
```