[PR #1233] feat(api): allow setting custom fields when creating a card via API (closes #1155) #883

Open
opened 2025-10-09 19:05:04 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/plankanban/planka/pull/1233
Author: @symonbaikov
Created: 7/4/2025
Status: 🔄 Open

Base: masterHead: feat/api-create-card-with-custom-fields


📝 Commits (1)

  • ffb9693 feat(api): allow setting custom fields when creating a card via API (closes #1155)

📊 Changes

2 files changed (+34 additions, -0 deletions)

View changed files

📝 server/api/controllers/cards/create.js (+7 -0)
📝 server/api/helpers/cards/create-one.js (+27 -0)

📄 Description

What’s new

  • Added support for setting custom fields when creating a card via the API.
  • Now you can pass a customFields object in the request body to /api/lists/{listId}/cards.
  • Custom field values will be set automatically if the specified group and field exist.

CleanShot 2025-07-04 at 21 50 50


Usage Example

Endpoint:
POST /api/lists/{listId}/cards

Request Body:

{
  "name": "Test card with custom field",
  "position": 1,
  "type": "project",
  "customFields": {
    "intern": {
      "SapID": "5635666"
    }
  }
}
  • intern — the name of the custom field group.
  • SapID — the name of the field within the group.
  • "5635666" — the value to set.

Note: The group and field must already exist in the Planka interface. If they do not exist, the values will be ignored.


Example Success Response

{
  "item": {
    "id": "1547345490861067225",
    "createdAt": "2025-07-04T17:19:16.631Z",
    "updatedAt": null,
    "type": "project",
    "position": 1,
    "name": "Test card with custom field",
    "description": null,
    "dueDate": null,
    "stopwatch": null,
    "commentsTotal": 0,
    "listChangedAt": "2025-07-04T17:19:16.628Z",
    "boardId": "1526128618923623429",
    "listId": "1530421234892801130",
    "creatorUserId": "1526127733044675585",
    "prevListId": null,
    "coverAttachmentId": null
  }
}

Notes & Limitations

  • If the specified custom field group or field does not exist, the value will be ignored, but the card will still be created.
  • If everything matches, the custom field values will be set immediately on card creation.
  • This feature is useful for integrations with external systems (e.g., to automatically create cards with unique identifiers).

Closes #1155


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/plankanban/planka/pull/1233 **Author:** [@symonbaikov](https://github.com/symonbaikov) **Created:** 7/4/2025 **Status:** 🔄 Open **Base:** `master` ← **Head:** `feat/api-create-card-with-custom-fields` --- ### 📝 Commits (1) - [`ffb9693`](https://github.com/plankanban/planka/commit/ffb96931843b141811cfabf65203537d18500de8) feat(api): allow setting custom fields when creating a card via API (closes #1155) ### 📊 Changes **2 files changed** (+34 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `server/api/controllers/cards/create.js` (+7 -0) 📝 `server/api/helpers/cards/create-one.js` (+27 -0) </details> ### 📄 Description ## What’s new - Added support for setting custom fields when creating a card via the API. - Now you can pass a `customFields` object in the request body to `/api/lists/{listId}/cards`. - Custom field values will be set automatically if the specified group and field exist. ![CleanShot 2025-07-04 at 21 50 50](https://github.com/user-attachments/assets/8e3198df-bf95-4410-929f-343684dd4807) --- ## Usage Example **Endpoint:** POST `/api/lists/{listId}/cards` **Request Body:** ```json { "name": "Test card with custom field", "position": 1, "type": "project", "customFields": { "intern": { "SapID": "5635666" } } } ``` - `intern` — the name of the custom field group. - `SapID` — the name of the field within the group. - `"5635666"` — the value to set. > **Note:** The group and field must already exist in the Planka interface. If they do not exist, the values will be ignored. --- ## Example Success Response ```json { "item": { "id": "1547345490861067225", "createdAt": "2025-07-04T17:19:16.631Z", "updatedAt": null, "type": "project", "position": 1, "name": "Test card with custom field", "description": null, "dueDate": null, "stopwatch": null, "commentsTotal": 0, "listChangedAt": "2025-07-04T17:19:16.628Z", "boardId": "1526128618923623429", "listId": "1530421234892801130", "creatorUserId": "1526127733044675585", "prevListId": null, "coverAttachmentId": null } } ``` --- ## Notes & Limitations - If the specified custom field group or field does not exist, the value will be ignored, but the card will still be created. - If everything matches, the custom field values will be set immediately on card creation. - This feature is useful for integrations with external systems (e.g., to automatically create cards with unique identifiers). --- Closes #1155 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2025-10-09 19:05:04 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/planka#883