Skip to content

Reorder API has Changed? #6830

Open
Open

Description

@gnilebein

I have a few scripts that automatically move Nextcloud Deck cards to another stack when overdue. These no longer work with the current version.

I use this endpoint as described in the API:

/boards/{boardId}/stacks/{stackId}/cards/{cardId}/reorder

In my opinion, this was also used for the web interface.

However, the web interface now uses this endpoint:

/cards/{cardId}/reorder as the endpoint.

Has the API changed here and the documentation has not been adapted?

Activity

  1. luka-nextcloud commented on Mar 19, 2025

    @luka-nextcloud
    Contributor

    @gnilebein As far as I know, the Rest API endpoints did not change. Please share system info and error messages.

  2. gnilebein commented on Mar 19, 2025

    @gnilebein
    Author

    @gnilebein As far as I know, the Rest API endpoints did not change. Please share system info and error messages.

    Thank you very much for your answer.. I was able to solve the problem myself by adapting my script. I have used this script in the past to move overdue cards from one stack to another.

    <?php
    
    // Dieses Script verschiebt Karten aus einem Stack "Warten" in einen anderen Stack, wenn das DueDate überschritten wurde.
    // Es unterstützt mehrere Boards.
    
    $boards = [
        ["id" => 6, "source" => 20, "destination" => 10]
    ];
    
    $username = "USER";
    $password = "PASSWORD";
    
    // Funktion zum Senden von cURL-Requests
    function sendCurlRequest($url, $method = "GET", $data = null)
    {
        global $username, $password;
    
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
        curl_setopt($ch, CURLOPT_TIMEOUT, 5);
        curl_setopt($ch, CURLOPT_HTTPHEADER, [
            'Content-Type: application/json',
            'OCS-APIRequest: true',
            'Authorization: Basic ' . base64_encode($username . ":" . $password)
        ]);
    
        if ($method !== "GET") {
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
            if ($data !== null) {
                curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
            }
        }
    
        $response = curl_exec($ch);
        
        if ($response === false) {
            error_log("cURL-Fehler: " . curl_error($ch));
        }
    
        curl_close($ch);
        return json_decode($response, true);
    }
    
    foreach ($boards as $board) {
        $url = "https://nextcloud.gnilebein.de/index.php/apps/deck/api/v1.1/boards/{$board['id']}/stacks/{$board['source']}";
        $cards = sendCurlRequest($url);
    
        if (!isset($cards['cards'])) {
            error_log("Fehler: Keine Karten gefunden für Board ID {$board['id']}");
            continue;
        }
    
        $data = ["order" => 0, "stackId" => $board['destination']];
    
        foreach ($cards['cards'] as $card) {
            if ($card['overdue'] > 1) {
                $moveUrl = "https://nextcloud.domain.tld/index.php/apps/deck/api/v1.1/boards/{$board['id']}/stacks/{$card['stackId']}/cards/{$card['id']}/reorder";
                sendCurlRequest($moveUrl, "PUT", $data);
            }
        }
    }

    So far it has worked to update the order and destination fields for the card. With this code, moving works again:

    foreach ($boards as $board) {
        $url = "https://nextcloud.gnilebein.de/index.php/apps/deck/api/v1.1/boards/{$board['id']}/stacks/{$board['source']}";
        $cards = sendCurlRequest($url);
    
        if (!isset($cards['cards'])) {
            error_log("Fehler: Keine Karten gefunden für Board ID {$board['id']}");
            continue;
        }
    
        foreach ($cards['cards'] as $card) {
            if ($card['overdue'] > 1) {
                $card['order'] = 999;
                $card['stackId'] = $board['destination'];
                $moveUrl = "https://nextcloud.domain.tld/index.php/apps/deck/api/v1.1/boards/{$board['id']}/stacks/{$card['stackId']}/cards/{$card['id']}/reorder";
                sendCurlRequest($moveUrl, "PUT", $card);
            }
        }
    }
  3. user8446 commented on Mar 20, 2025

    @user8446

    Hi you mentioned it changed with the "current version". Did you update to NC 31 which upgrades deck to 1.15.0?

    I use that API as well and want to be on the lookout for it.

  4. nikhub commented on Jul 7, 2025

    @nikhub

    I can confirm that the behavior of the API has changed after updating Deck.
    Currently I am running Nextcloud 31.0.6 with Deck version 1.15.1.

    I am also using the REST API to move cards. Before updating Deck (or NC respectively) moving Cards worked fine.
    Now I still get a "200 Success" response, but the card stays at its position.

    @gnilebein
    Can you please explain, what you changed in your code? I think I roughly understand what you did, but am not that familiar with PHP.
    Mainly you are now passing indivual objects of each card to the CurlRequest instead of the common data object and you changed the order from 0 to 999. Am I missing something?

  5. nikhub commented on Jul 31, 2025

    @nikhub

    I just updated to Deck version 1.15.2. The issue is still active.
    Does anybody have an idea for a workaround? Currently I am unable to use the API properly as this is a major feature of Deck.

  6. user8446 commented on Aug 1, 2025

    @user8446

    I am on deck v 1.15.2 as well and reordering is still working with no changes on our end.

    However, we are just creating a new card in the stack and then reordering it to the top in the same stack (order=0). We are not moving it to a different stack.

    Maybe that is where the issue is?

  7. nikhub commented on Aug 3, 2025

    @nikhub

    I am on deck v 1.15.2 as well and reordering is still working with no changes on our end.

    However, we are just creating a new card in the stack and then reordering it to the top in the same stack (order=0). We are not moving it to a different stack.

    Maybe that is where the issue is?

    Sorry, I was a little imprecise.
    Yes, I want to move cards from one stack to another. I did not try to move cards within a stack, yet.

  8. vdiezel commented on Aug 5, 2025

    @vdiezel
    Contributor

    The reorder-API for cards via REST is broken, as a workaround we simply used the /cards/{cardId}/reorder endpoint that the native client also uses. I have put up a PR that should fix the REST endpoint, too.

  9. Olen commented on Nov 25, 2025

    @Olen

    I just checked, and the fixes from #7154 and friends have not resolved this issue.
    I run the latest beta, and even verified in the source that the changes from #7276 is applied.

    I still get a 200-response, but the card is NOT moved to another stack when I use the path /apps/deck/api/v1.1/boards/{board_id}/stacks/{stack_id}/cards/{card_id}/reorder

    I have tested with both the minimal parameters specified in the docs:

    {
      stackId: <new id>,
      order: 1234,
    }
    

    And with the full card-config (but changing to the new stackId obviousy)

    Sending the entire card-config (with the new stackId) to the endpoint /apps/deck/cards/{card_id}/reorder moves the card to the new stack as expected.

  10. aikusuma commented on Dec 9, 2025

    @aikusuma

    I just checked, and the fixes from #7154 and friends have not resolved this issue. I run the latest beta, and even verified in the source that the changes from #7276 is applied.

    I still get a 200-response, but the card is NOT moved to another stack when I use the path /apps/deck/api/v1.1/boards/{board_id}/stacks/{stack_id}/cards/{card_id}/reorder

    I have tested with both the minimal parameters specified in the docs:

    {
      stackId: <new id>,
      order: 1234,
    }
    

    And with the full card-config (but changing to the new stackId obviousy)

    Sending the entire card-config (with the new stackId) to the endpoint /apps/deck/cards/{card_id}/reorder moves the card to the new stack as expected.

    I have same problem with you,
    Tried many method and didnt works
    Please fix this or document it effectively. I wasted hours just trying to move a card.

  11. Olen commented on Aug 3, 2026

    @Olen

    Some findings from digging into this on Deck 1.17.3, in case they help.

    Both reorder routes still exist, so the documented one has not been removed:

    // appinfo/routes.php
    :51   ['name' => 'card#reorder',     'url' => '/cards/{cardId}/reorder', 'verb' => 'PUT'],
    :107  ['name' => 'card_api#reorder', 'url' => '/api/v{apiVersion}/boards/{boardId}/stacks/{stackId}/cards/{cardId}/reorder', 'verb' => 'PUT'],

    CardApiController::reorder() and CardController::reorder() both delegate to the same CardService::reorder(), so they behave identically.

    A side effect worth knowing about either way: reorder rewrites lastModified on every card in the target stack, not just the moved one. CardService::reorder() does $this->cardMapper->findAll($stackId) and writes each card back through CardMapper::update(), whose $updateModified parameter defaults to true and therefore calls setLastModified(time()) on all of them.

    Measured on a real board: moving a single card into a stack of 32 rewrote lastModified on all 32, including cards created years earlier and untouched since. That makes lastModified unusable for "when did this card last actually change".

    An alternative that avoids it: a card can be moved with the ordinary documented update endpoint by addressing it at the target stack, since CardService::update() takes stackId and sets it without touching any other card:

    PUT /index.php/apps/deck/api/v1.0/boards/{boardId}/stacks/{TARGET_STACK_ID}/cards/{cardId}
    

    Same board, same card, moving into that 32-card stack: the card moved, order was honoured, and zero of the other 32 cards had lastModified rewritten.

    One caveat if you try this. CardService::update() declares description = '', duedate = null and friends as defaulted parameters, so anything you omit is overwritten rather than left alone. A minimal payload of title/type/owner moved the card correctly but blanked its description and due date. Resending the card's full current state preserved everything. So this is only a safe substitute for reorder if you round-trip the whole card.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions