Back to Wekan

Wekan REST API

docs/API/REST-API.md

9.647.9 KB
Original Source

REST API is not complete yet, please add missing functionality with pull requests to devel branch.

If you are in a hurry, you can use these to have more functionality:

For workflows see If-this-then-that issue than mentions Huginn, Flogo etc.

Wekan REST API

The REST API allows you to control and extend Wekan with ease.

If you are an end-user and not a dev or a tester, create an issue to request new APIs.

All API calls in the documentation are made using curl. However, you are free to use Java / Python / PHP / Golang / Ruby / Swift / Objective-C / Rust / Scala / C# or any other programming languages.

Production Security Concerns

When calling a production Wekan server, ensure it is running via HTTPS and has a valid SSL Certificate. The login method requires you to post your username and password in plaintext, which is why we highly suggest only calling the REST login api over HTTPS. Also, few things to note:

  • Only call via HTTPS
  • Implement a timed authorization token expiration strategy
  • Ensure the calling user only has permissions for what they are calling and no more

Summary

Authentication

HTTP MethodUrlShort Description
POST/users/loginAuthenticate with the REST API.

Users

HTTP MethodUrlShort Description
POST/users/registerRegister a new user.
POST/api/usersCreate a new user.
PUT/api/users/:idDisable an existing user.
PUT/api/users/:idEnable an existing user.
PUT/api/users/:idAdmin takes the ownership.
DELETE/api/users/:idDelete an existing user. (Warning)
GET/api/users/:idGets a user's information.
GET/api/usersAll of the users.
GET/api/userGets a logged-in user.

Cards

HTTP MethodUrlShort Description
POST/api/boards/:boardId/lists/:listId/cardsAdd a card to a list, board, and swimlane.
PUT/api/boards/:boardId/lists/:fromListId/cards/:cardIdUpdate a card.
DELETE/api/boards/:boardId/lists/:listId/cards/:cardIdDelete a card.

Board Domain Sharing

HTTP MethodUrlShort Description
GET/api/boards/:boardId/domainsList the email domains a board is shared with.
POST/api/boards/:boardId/domainsShare a board with an email domain.
DELETE/api/boards/:boardId/domains/:domainStop sharing a board with an email domain.

GlobalAdmin Settings

HTTP MethodUrlShort Description
GET/api/settingsRead the Admin Panel global settings.
PUT/api/settingsUpdate the Admin Panel global settings.

Login

URLRequires AuthHTTP Method
/users/loginnoPOST

Payload

Authentication with username

ArgumentExampleRequiredDescription
usernamemyusernameRequiredYour username
passwordmy$up3erP@ssw0rdRequiredYour password

Authentication with email

ArgumentExampleRequiredDescription
email[email protected]RequiredYour email
passwordmy$up3erP@ssw0rdRequiredYour password
  • Notes:
  • You will need to provide the token for any of the authenticated methods.

Example Call - As Form Data

DOES NOT WORK ! Please use As JSON example below ! https://github.com/wekan/wekan/issues/4807

bash
curl http://localhost:3000/users/login \
     -d "username=myusername&password=mypassword"
bash
curl http://localhost:3000/users/login \
     -d "[email protected]&password=mypassword"

Example Call - As JSON

THIS WORKS !! Alternatively, look at api.py example at https://github.com/wekan/wekan

NOTE: Username and password is case sensitive. So type BIG and small letters correctly.

bash
curl -H "Content-type:application/json" \
      http://localhost:3000/users/login \
      -d '{ "username": "myusername", "password": "mypassword" }'
bash
curl -H "Content-type:application/json" \
      http://localhost:3000/users/login \
      -d '{ "email": "[email protected]", "password": "mypassword" }'

Result

json
{
  "id": "user id",
  "token": "string",
  "tokenExpires": "ISO encoded date string"
}

Result example

json
{
  "id": "XQMZgynx9M79qTtQc",
  "token": "ExMp2s9ML1JNp_l11sIfINPT3wykZ1SsVwg-cnxKdc8",
  "tokenExpires": "2017-12-15T00:47:26.303Z"
}

Board Domain Sharing

Boards can be shared with every user on an email domain (for example everyone with an @example.com address). These endpoints list, add and remove the domains a board is shared with.

A board admin (or a site admin) is required to add or remove domains. Domains are validated: they are stored lowercase, must contain a ., and must not contain @ or whitespace.

The matching api.py commands are boarddomains, addboarddomain and removeboarddomain.

List board domains

URLRequires AuthHTTP Method
/api/boards/:boardId/domainsyesGET
bash
curl -H "Authorization: Bearer t7iYB86mXoLfP_XsMegxF41oKT7iiA9lDYiKVtXcctl" \
     http://localhost:3000/api/boards/abcd1234/domains

Add a board domain

URLRequires Auth (board admin)HTTP Method
/api/boards/:boardId/domainsyesPOST
bash
curl -H "Authorization: Bearer t7iYB86mXoLfP_XsMegxF41oKT7iiA9lDYiKVtXcctl" \
     -H "Content-type:application/json" \
     -X POST \
     http://localhost:3000/api/boards/abcd1234/domains \
     -d '{ "domain": "example.com" }'

Remove a board domain

URLRequires Auth (board admin)HTTP Method
/api/boards/:boardId/domains/:domainyesDELETE
bash
curl -H "Authorization: Bearer t7iYB86mXoLfP_XsMegxF41oKT7iiA9lDYiKVtXcctl" \
     -X DELETE \
     http://localhost:3000/api/boards/abcd1234/domains/example.com

GlobalAdmin Settings

These endpoints read and update the Admin Panel global settings (registration, product name, logos, custom head / manifest, accessibility and support pages, and so on). They are global-admin only.

Updates are applied through a field whitelist, so only the supported settings fields can be changed. For security, mailServer / SMTP credentials are never returned by GET and are never writable by PUT.

The matching api.py commands are getsettings and editsettings <field> <value>.

Get settings

URLRequires Auth (global admin)HTTP Method
/api/settingsyesGET
bash
curl -H "Authorization: Bearer t7iYB86mXoLfP_XsMegxF41oKT7iiA9lDYiKVtXcctl" \
     http://localhost:3000/api/settings

Update settings

URLRequires Auth (global admin)HTTP Method
/api/settingsyesPUT
bash
curl -H "Authorization: Bearer t7iYB86mXoLfP_XsMegxF41oKT7iiA9lDYiKVtXcctl" \
     -H "Content-type:application/json" \
     -X PUT \
     http://localhost:3000/api/settings \
     -d '{ "productName": "My WeKan", "disableRegistration": true }'