|
| 1 | +--- |
| 2 | +title: Plane API Documentation |
| 3 | +sidebar_label: Introduction |
| 4 | +description: Use the Plane API to programatically read and write changes to your Workspaces, Projects, Work Items and much more. |
| 5 | +sidebar_position: 0 |
| 6 | +--- |
| 7 | + |
| 8 | +{frontMatter.description && <h3 className="description">{frontMatter.description}</h3>} |
| 9 | + |
| 10 | +:::info |
| 11 | +The Plane cloud API is available at `https://api.plane.so/` |
| 12 | +::: |
| 13 | + |
| 14 | +## Quick start |
| 15 | + |
| 16 | +### 1. Get your API key |
| 17 | + |
| 18 | +To make requests to the Plane API, you'll need an API key. This key is used to |
| 19 | +verify your client's identity and permissions. The key must be passed as the |
| 20 | +value of the `X-API-Key` header. |
| 21 | + |
| 22 | +Enough talk. Let's get you an API key! |
| 23 | + |
| 24 | +:::tip |
| 25 | +You must have a Plane account or be registered to your instance to generate a key. |
| 26 | +::: |
| 27 | + |
| 28 | +1. Log into your Plane account and go to **Profile Settings** |
| 29 | +  |
| 30 | +2. Go to **Personal Access Tokens** |
| 31 | +  |
| 32 | +3. Click **Add personal access token** |
| 33 | +  |
| 34 | +4. Enter a title and description to help you remember why you created this key |
| 35 | +5. Optionally set an expiry date for the key, after which time the key will no longer be valid |
| 36 | + |
| 37 | +:::danger |
| 38 | +Treat your API key like a password. Keep it secret. Keep it safe. It is |
| 39 | +important to store your API key securely and keep it confidential to prevent |
| 40 | +unauthorized access to your account. Do not share it or expose it in |
| 41 | +client-side code. |
| 42 | +::: |
| 43 | + |
| 44 | +### 2. Execute an HTTP request 🔄 |
| 45 | + |
| 46 | +When issuing HTTP requests to the API, you'll always set the `x-api-key` |
| 47 | +request header to your API key. For example, if using `curl` this looks like: |
| 48 | + |
| 49 | +```bash |
| 50 | +curl -L 'https://api.plane.so/api/v1/workspaces/:slug/projects/:project_id/issues/' \ |
| 51 | +-H 'Accept: application/json' \ |
| 52 | +-H 'X-API-Key: <X-API-Key>' |
| 53 | +``` |
| 54 | + |
| 55 | +Run the above command to receive your first response from the Plane API. |
| 56 | + |
| 57 | +### 3. Congratulations 🥳 |
| 58 | + |
| 59 | +Congratulations! You've successfully run your first HTTP request using the |
| 60 | +[Plane](https://plane.so) API. Next, browse the rest of our documentation for |
| 61 | +more examples of how you can integrate your project! 😎 |
| 62 | + |
| 63 | +___ |
| 64 | + |
| 65 | +## General API usage |
| 66 | + |
| 67 | +### Base URL |
| 68 | + |
| 69 | +All requests to the Plane Cloud API must be made to the following base URL: |
| 70 | + |
| 71 | +``` |
| 72 | +https://api.plane.so/ |
| 73 | +``` |
| 74 | + |
| 75 | +:::info |
| 76 | +If you're using a self-hosted instance of Plane, your API base URL will differ based on your custom domain and setup. |
| 77 | +::: |
| 78 | + |
| 79 | +### Security recommendations |
| 80 | + |
| 81 | +- **Keep the API Key Secret**: Treat your API key like a password. Do not share it or expose it in client-side code. |
| 82 | +- **Regenerate Key If Compromised**: If you suspect that your API key has been compromised, generate a new one immediately and update your applications. |
| 83 | + |
| 84 | +### API key errors |
| 85 | + |
| 86 | +- If the **`X-API-Key`** header is not included, the API will return an error indicating that authentication is required. |
| 87 | +- If the provided API key is invalid or expired, the API will return an error message indicating an authentication failure. |
| 88 | + |
| 89 | +### HTTP methods |
| 90 | + |
| 91 | +HTTP defines a set of request methods, also known as HTTP verbs, to indicate the desired action for a given resource. |
| 92 | + |
| 93 | +Given below is the list of methods commonly adopted by Plane's API: |
| 94 | + |
| 95 | +|Verb |Description |Example | |
| 96 | +|------|---------------------------------------------------|-----------------------------------| |
| 97 | +|GET |Requests a representation of the specified resource|Fetch all work items from a project| |
| 98 | +|POST |Submits an entity to the specified resource |Create a project | |
| 99 | +|DELETE|Deletes the specified resource |Delete a work item | |
| 100 | +|PATCH |Applies partial modifications to a resource |Edit a module | |
| 101 | + |
| 102 | +### Status codes |
| 103 | + |
| 104 | +Given below is the list of the most commonly encountered success responses: |
| 105 | + |
| 106 | +| Status Code | Description | |
| 107 | +|----------------|----------------------------------------------------------------------------------------| |
| 108 | +| 200 OK | The request succeeded. Generally used in GET or PATCH requests. | |
| 109 | +| 201 Created | The request succeeded and a new resource was created. Generally used in POST requests. | |
| 110 | +| 204 No Content | The request succeeded and no body is returned. Generally used in DELETE requests. | |
| 111 | + |
| 112 | +### Error responses |
| 113 | + |
| 114 | +Given below is the list of the most commonly encountered error responses: |
| 115 | + |
| 116 | +| Status Code | Description | |
| 117 | +|---------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 118 | +| 400 Bad Request | The server cannot or will not process the request due to something that is perceived to be a client error. | |
| 119 | +| 401 Unauthorized | Although the HTTP standard specifies "unauthorized", semantically, this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. | |
| 120 | +| 404 Not Found | The server cannot find the requested resource. This means the URL is not recognized. | |
| 121 | +| 429 Throttling Error | The server has received too many requests from your client within a short period of time. Retry the request later. You can read more in our [rate-limiting](#rate-limiting) section. | |
| 122 | +| 500 Internal Server Error | The server has encountered a situation it does not know how to handle, and failed to process the request. | |
| 123 | +| 502 Bad Gateway | The server received an invalid response from another service which was required to handle the request. | |
| 124 | +| 503 Service Unavailable | The server is not ready to handle the request. Common causes are a server that is down for maintenance or overloaded. | |
| 125 | +| 504 Gateway Timeout | The server was unable to receive a timely response from a downstream service. |
| 126 | + |
| 127 | + |
| 128 | +--- |
| 129 | + |
| 130 | +## Pagination |
| 131 | + |
| 132 | +The Plane API implements a cursor-based pagination system, allowing clients to |
| 133 | +efficiently navigate through large datasets. The system uses a cursor parameter |
| 134 | +to manage the position and direction of pagination. |
| 135 | + |
| 136 | +### Querystring parameters |
| 137 | + |
| 138 | +Paging is controlled by clients via the following querystring parameters. |
| 139 | + |
| 140 | +- **`per_page` (optional)**: Number of items to display per page. Defaults to 100. The maximum allowed value is 100. |
| 141 | +- **`cursor` (optional)**: Cursor string (see below) to navigate to a specific page. If not provided, pagination starts from the first page. |
| 142 | + |
| 143 | +### Cursor string format |
| 144 | + |
| 145 | +The cursor string is formatted as **`value:offset:is_prev`**, where: |
| 146 | + |
| 147 | +- **`value`** represents the page size (number of items per page) |
| 148 | +- **`offset`** is the current page number (starting from 0) |
| 149 | +- **`is_prev`** indicates whether the cursor is moving to the previous page (**`1`**) or to the next page (**`0`**) |
| 150 | + |
| 151 | +### Example: Fetching the first page |
| 152 | + |
| 153 | +``` |
| 154 | +GET /api/v1/workspaces/:workspace-slug/projects/:project_id/issues/?per_page=20 |
| 155 | +``` |
| 156 | + |
| 157 | +#### Pagination response |
| 158 | + |
| 159 | +The paginated response includes the following fields: |
| 160 | + |
| 161 | +- **`next_cursor`**: Cursor string for the next page |
| 162 | +- **`prev_cursor`**: Cursor string for the previous page |
| 163 | +- **`next_page_results`**: Boolean indicating if there are more results after the current page |
| 164 | +- **`prev_page_results`**: Boolean indicating if there are results before the current page |
| 165 | +- **`count`**: Total number of items on the current page |
| 166 | +- **`total_pages`**: Estimated total number of pages |
| 167 | +- **`total_results`**: Total number of items across all pages |
| 168 | +- **`extra_stats`**: Additional statistics, if any |
| 169 | +- **`results`**: Array of items for the current page |
| 170 | + |
| 171 | +Here's an example response for the first page of results: |
| 172 | + |
| 173 | +```json |
| 174 | +{ |
| 175 | + "next_cursor": "20:1:0", |
| 176 | + "prev_cursor": "", |
| 177 | + "next_page_results": true, |
| 178 | + "prev_page_results": false, |
| 179 | + "count": 20, |
| 180 | + "total_pages": 50, |
| 181 | + "total_results": 1000, |
| 182 | + "extra_stats": {}, |
| 183 | + "results": [ ... items ... ] |
| 184 | +} |
| 185 | +``` |
| 186 | + |
| 187 | +### Example: Fetching the next page |
| 188 | + |
| 189 | +``` |
| 190 | +GET /api/v1/workspaces/:workspace-slug/projects/:project_id/issues?per_page=20&cursor=20:1:0 |
| 191 | +``` |
| 192 | + |
| 193 | +#### Pagination next page response |
| 194 | + |
| 195 | +```json |
| 196 | +{ |
| 197 | + "next_cursor": "20:2:0", |
| 198 | + "prev_cursor": "20:0:1", |
| 199 | + "next_page_results": true, |
| 200 | + "prev_page_results": true, |
| 201 | + "count": 20, |
| 202 | + "total_pages": 50, |
| 203 | + "total_results": 1000, |
| 204 | + "extra_stats": {}, |
| 205 | + "results": [ ... items ... ] |
| 206 | +} |
| 207 | +``` |
| 208 | + |
| 209 | +### Pagination errors |
| 210 | + |
| 211 | +- **Invalid Cursor Format**: If the provided cursor string is not in the correct format, the API will respond with an error message indicating an invalid cursor format. |
| 212 | +- **Pagination Limits**: Requests exceeding the maximum **`per_page`** limit will receive an error response detailing the maximum allowed value. |
| 213 | + |
| 214 | +--- |
| 215 | + |
| 216 | +## Rate limiting |
| 217 | + |
| 218 | +To ensure fair usage and maintain the overall quality of service for the |
| 219 | +community, the Plane API implements rate limiting. Rate limiting restricts the |
| 220 | +number of requests a client can make within a certain time frame. |
| 221 | + |
| 222 | +### Rate limit details |
| 223 | + |
| 224 | +- **Limit**: Each client is limited to 60 requests per minute |
| 225 | +- **Reset Interval**: The rate limit counter resets every minute |
| 226 | +- **Scope of Limitation**: The rate limit applies to all requests made with a given API key |
| 227 | + |
| 228 | +### Identifying your rate limit status |
| 229 | + |
| 230 | +Your current rate limit status is communicated in the response headers of each API request: |
| 231 | + |
| 232 | +- **`X-RateLimit-Remaining`**: The number of requests remaining in the current rate limit window |
| 233 | +- **`X-RateLimit-Reset`**: The time at which the current rate limit window resets (in UTC epoch seconds) |
| 234 | + |
| 235 | +``` |
| 236 | +X-RateLimit-Remaining: 45 |
| 237 | +X-RateLimit-Reset: 1700327957 |
| 238 | +``` |
| 239 | + |
| 240 | +--- |
| 241 | + |
| 242 | +## Fine tuning response fields |
| 243 | + |
| 244 | +The Plane API provides flexible data retrieval capabilities through two powerful query |
| 245 | +parameters: `fields` and `expand`. These parameters allow clients to tailor the |
| 246 | +response data to their specific needs, optimizing both the payload size and the |
| 247 | +clarity of the response. |
| 248 | + |
| 249 | +### Fields parameter |
| 250 | + |
| 251 | +The `fields` parameter enables clients to selectively retrieve only a subset of |
| 252 | +fields for a given resource. |
| 253 | + |
| 254 | +:::tip |
| 255 | +The `fields` parameter is particularly useful for reducing response time, size |
| 256 | +and bandwidth, especially when your client requires only specific pieces of data. |
| 257 | +::: |
| 258 | + |
| 259 | +The **`fields`** parameter accepts a comma-separated list of field names that |
| 260 | +the client wants to be included in the response. For example, to include only |
| 261 | +the `id`, `name`, and `description` fields, send the following querystring parameters: |
| 262 | + |
| 263 | +``` |
| 264 | +GET /api/v1/workspaces/:workspace-slug/projects/:project_id/issues/?fields=id,name,description |
| 265 | +``` |
| 266 | + |
| 267 | +#### Fields parameter error handling |
| 268 | + |
| 269 | +Invalid or unrecognized field names passed in the **`fields`** parameter will |
| 270 | +result in an error response, indicating which fields are invalid. |
| 271 | + |
| 272 | +### Expand parameter |
| 273 | + |
| 274 | +The `expand` parameter allows clients to request additional related information to |
| 275 | +be included in the response. This is useful for retrieving detailed information |
| 276 | +about nested resources without making separate API calls. |
| 277 | + |
| 278 | +For example, to return the resource data along with expanded information about |
| 279 | +the `assignees` and `state`, send the following querystring parameters: |
| 280 | + |
| 281 | +``` |
| 282 | +GET /api/v1/workspaces/:workspace-slug/projects/:project_id/issues/?expand=assignees,state |
| 283 | +``` |
| 284 | + |
| 285 | +#### Expand parameter error handling |
| 286 | + |
| 287 | +If **`expand`** is used on fields that cannot be expanded, an appropriate error message will be returned. |
0 commit comments