Skip to content
Rasmus Wulff Jensen edited this page Apr 1, 2025 · 62 revisions

This is the Main Client to communicate with the Trello API (aka everything is done via this)

Creating a new TrelloClient

In order to instantiate the client you need to provide:

Option Description
ApiKey (Required) The Trello API Key you get on https://trello.com/power-ups/admin/
Token (Required) Your Authorization Token you generate get on https://trello.com/power-ups/admin/
Options (Optional) Various options for the client (if null default options will be used) See below for details
HttpClient (Optional) Optional HTTP Client if you wish to specify it on your own (else an internal static HttpClient will be used for re-use)

Example

TrelloClient client = new TrelloDotNet.TrelloClient("APIKEY", "TOKEN"); //IMPORTANT: Remember to NOT leave Key and Token in clear text!

//Get all boards that Token Owner can Access
List<Board> boards = await client.GetBoardsCurrentTokenCanAccessAsync();

//Get a specific board
Board board = await client.GetBoardAsync("<boardId>");

//Get Lists on a board
List<List> lists = await client.GetListsOnBoardAsync("<boardId>");

//Get Cards on Board
List<Card> cardsOnBoard = await trelloClient.GetCardsOnBoardAsync("<boardId>");

//Get Cards in a specific List
List<Card> cardsInList = await trelloClient.GetCardsInListAsync("<listId>");

//Get a specific card
Card card = await client.GetCardAsync("<cardId>");

//Add a card (Simple)
AddCardOptions newCardOptions = new AddCardOptions("<listId>", "My Card", "My Card description");
Card newCard = await client.AddCardAsync(newCardOptions);

//Add a Card (Advanced with all options set)
Card newAdvancedCard = await client.AddCardAsync(new AddCardOptions
{
    //Mandatory options
    ListId = "<listId>",
    Name = "My Card",

    //Optional options
    Description = "Description of My Card",
    Start = DateTimeOffset.Now,
    Due = DateTimeOffset.Now.AddDays(3),
    Cover = new CardCover(CardCoverColor.Blue, CardCoverSize.Normal),
    LabelIds = new List<string>
    {
        "<labelId1>",
        "<labelId2>",
    },
    MemberIds = new List<string>
    {
        "<memberId1>",
        "<memberId2>"
    },
    Checklists = new List<Checklist>
    {
        new Checklist("Checklist 1", new List<ChecklistItem>
        {
            new ChecklistItem("Item 1"),
            new ChecklistItem("Item 2"),
            new ChecklistItem("Item 3")
        }),
        new Checklist("Checklist 2", new List<ChecklistItem>
        {
            new ChecklistItem("Item A"),
            new ChecklistItem("Item B"),
            new ChecklistItem("Item C")
        }),
    },
    AttachmentUrlLinks = new List<AttachmentUrlLink>
    {
        new AttachmentUrlLink("https://www.google.com", "Google")
    },
    AttachmentFileUploads = new List<AttachmentFileUpload>
    {
        new AttachmentFileUpload(File.OpenRead(@"<pathToFile>"), "<Filename>", "<FileDescription>")
    },
    CustomFields = new List<AddCardOptionsCustomField>
    {
        new AddCardOptionsCustomField(customField1OnBoard, "ABC"),
        new AddCardOptionsCustomField(customField2OnBoard, 123),
    }
});

//Update a Card (with new name and description and removal of Due Date)
var updateCard = await TrelloClient.UpdateCardAsync("<cardId>", [
    CardUpdate.Name("New Name"),
    CardUpdate.Description("New Description"),
    CardUpdate.DueDate(null),
]);

//Add a Checklist to a card
var checklistItems = new List<ChecklistItem>
{
    new("ItemA"),
    new("ItemB"),
    new("ItemC")
};
Checklist newChecklist = new Checklist("Sample Checklist", checklistItems);
Checklist addedChecklist = await client.AddChecklistAsync("<cardId>", newChecklist);

TrelloClientOptions

The TrelloClientOptions can be passed optionally to the TrelloClient Constructor with the following options:

Option Description
ApiCallExceptionOption Control level of URL Details are shown in Exceptions from calls to the API
AllowDeleteOfBoards Controls if it is allowed to delete Boards (secondary confirmation)
AllowDeleteOfOrganizations Controls if it is allowed to delete Organizations (secondary confirmation)
MaxRetryCountForTokenLimitExceeded Controls how many automated Retries the API should try in case if get an 'API_TOKEN_LIMIT_EXCEEDED' error from Trello (Default 3) set to -1 to disable the system
DelayInSecondsToWaitInTokenLimitExceededRetry Controls how long in seconds system should wait between retries, should it receive an 'API_TOKEN_LIMIT_EXCEEDED' error from Trello (Default 1 sec)

Features of the API

Action Features

Actions in Trello are the 'things' the Members do on a Board... There are common things like 'Create a Card' or 'Add a Label to a Card', and more obscure things like example 'Accept Enterprise Join Request'. In total, there are over 75 different types of Actions. You can retrieve these events via the API to example get a list of things that happened on a specific card.

Tip: There is a list of different events in struct TrelloDotNet.Model.Webhook.WebhookActionTypes for you to consume.

NB: You can max get the last 1000 Actions that have happened.

Feature Description
GetActionsOfBoardAsync Get the most recent Actions (Changelog Events) of a board
GetActionsOnCardAsync Get the most recent Actions (Changelog Events) on a Card
GetActionsForListAsync Get the most recent Actions (Changelog Events) for a List
GetActionsForMemberAsync Get the most recent Actions (Changelog Events) for a Member
GetActionsForOrganizationsAsync Get the most recent Actions (Changelog Events) for an Organization

Attachment Features

Cards can have Attachments of various types (Links and Files) and these methods allow you to add, get and delete the attachments.

Feature Description
AddAttachmentToCardAsync Add an Attachment to a Card
GetAttachmentOnCardAsync Get a Specific Attachment on a Card
GetAttachmentsOnCardAsync Get Attachments on a card
DeleteAttachmentOnCardAsync Delete an Attachments on a card
DownloadAttachmentAsync Download an Attachment on a card

Board Features

Boards are where you have your Lists (and Cards on those lists). The API gives standard CRUD features (good if you programmatically wish to spin up template Boards in large organizations). A Board's 'parent' is an Organization (Workspace)

Feature Description
AddBoardAsync Add a new Board
GetBoardAsync Get a Board by its Id
GetBoardsForMemberAsync Get the Boards that the specified member has access to
GetBoardsCurrentTokenCanAccessAsync Get the Boards that the token provided to the TrelloClient can Access
GetBoardsInOrganization Get the Boards in an Organization
UpdateBoardAsync Update a Board
CloseBoardAsync Close (Archive) a Board
ReOpenBoardAsync ReOpen a Board
DeleteBoardAsync Delete an entire board

Card Features

Cards are the main feature of any Trello Board. There are associated with a List and have various core fields (Name, Description, Dates) and Links to other Trello artifacts (Labels, Members, Checklists, Attachments, Stickers, and Covers). Via the API you can do standard CRUD operations and link/unlink the other artifacts.

Tip: On the various methods that get Cards you can optionally specify GetCardOptions to control what parts of a card is returned and what cards are returned when multiple is returned.

Feature Description
AddCardAsync Add a Card
GetCardAsync Get Card by its Id
GetCardsOnBoardAsync Get all open cards on un-archived lists
GetCardsInInboxAsync Get Cards in the users inbox
GetCardsInListAsync Get all open cards on a specific list
GetCardsForMemberAsync Get all Cards a Member is on (across multiple boards)
MirrorCardAsync Mirror a Card
UpdateCardAsync Update a Card
ArchiveCardAsync Archive (Close) a Card
ReOpenCardAsync ReOpen (Send back to board) a Card
ArchiveAllCardsInListAsync Archive all cards on in a List
MoveAllCardsInListAsync Move all cards of a list to another list
MoveCardToListAsync Move card to another list on the board
DeleteCardAsync Delete a Card
SetDueDateOnCardAsync Set Due Date on a card
SetStartDateOnCardAsync Set Due Date on a card
SetStartDateAndDueDateOnCardAsync Set Start and Due Date on a card

Checklist Features

On a Card, you can have one or more Checklists that are essential 'SubTasks' for the card. If you are a free user they are simple checklists, while on a premium account, you can also assign members and due dates to each Check-item. Via the API you can do standard CRUD operations.

Feature Description
AddChecklistAsync Add a Checklist to the card or Add a Checklist to the card based on an existing checklist (as a copy)
GetChecklistAsync Get a Checklist with a specific Id
GetChecklistsOnBoardAsync Get a list of Checklists that are used on cards on a specific Board
GetChecklistsOnCardAsync Get a list of Checklists that are used on a specific card
UpdateChecklistItemAsync Update a Check-item on a Card
DeleteChecklistAsync Delete a Checklist
DeleteChecklistItemAsync Delete a Checklist Item from a checklist

Comments Features

On a Card, the Members of a Board can add Comments (Comments in Trello are essentially special Actions so they will also appear there). Via the API you can do standard CRUD operations.

Feature Description
AddCommentAsync Add a new Comment on a Card
GetAllCommentsOnCardAsync Get All Comments on a Card
GetCommentReactions The reactions of a comment
GetPagedCommentsOnCardAsync Get Paged Comments on a Card
UpdateCommentActionAsync Update a comment Action (aka only way to update comments as they are not seen as their own objects)
DeleteCommentActionAsync Delete a Comment

Cover Features

Covers are a special visual feature on Cards that can help the card stand out (color at, the top, the full coloring of the card, or have an image at the top of the card). Via the API you can do standard CRUD operations for covers.

Feature Description
AddCoverToCardAsync Add a Cover to a card. Tip: It is also possible to update the cover via UpdateCardAsync
UpdateCoverOnCardAsync Update a Cover to a card (this is equivalent to AddCoverToCardAsync, but here for discover-ability. Tip: It is also possible to update the cover via UpdateCardAsync)
RemoveCoverFromCardAsync Remove a cover from a Card

Custom Field Features

NB: Custom Fields are a Paid Trello Feature only :-/ Custom Fields are as the name says, fields that you can make yourself in order to add custom values to Cards. As an example, Trello does not have a default Priority field, but with a custom field, you could make one.

Feature Description
GetCustomFieldsOnBoardAsync Get Custom Fields of a Board
UpdateCustomFieldValueOnCardAsync Update a Custom field on a Card
ClearCustomFieldValueOnCardAsync Clear a Custom field on a Card
GetCustomFieldItemsForCardAsync Get Custom Fields for a Card (Tip: Use Extension methods GetCustomFieldValueAsXYZ for a handy way to get values)

Generic Features

This API does not cover every single little or obscure feature the Trello API has to offer, but it could be that you wish to use something that is not exposed anyway. For that reason, Generic Post, Put, Get, and Delete methods exist in the API where you can provide the endpoint, parameters and the API will take care of all the core stuff of the call

Tip: If you feel it should be in the product then submit it on the Issues page).

Feature Description
PostAsync Custom Post Method to be used on unexposed features of the API
GetAsync Custom Get Method to be used on unexposed features of the API
PutAsync Custom Put Method to be used on unexposed features of the API
DeleteAsync Custom Delete Method to be used on unexposed features of the API

Label Features

Labels (or Tags as they are called in other systems) can be assigned to Cards to categorize them. The API provides both CRUD operations for the management of Labels (they belong to a board) and the add/removal of labels on Cards.

Feature Description
AddLabelsToCardAsync Add a Label to a Card
RemoveLabelsFromCardAsync Remove a Label of a Card
RemoveAllLabelsFromCardAsync Remove all Labels of a Card
GetLabelsOfBoardAsync Get List of Labels defined for a board
AddLabelAsync Add a new label to the Board (Not to be confused with AddLabelsToCardAsync that assign labels to cards)
UpdateLabelAsync Update the definition of a label (Name and Color)
DeleteLabelAsync Delete a Label from the board and remove it from all cards it was added to

List Features

Lists are the 'Columns' you see on your Board and hold your Cards. They are pretty simple structures with just an Id and a Name. Via the API you can do standard CRUD operations.

Feature Description
AddListAsync Add a List to a Board
GetListAsync Get a specific List (Column) based on its Id
GetListsOnBoardAsync Get Lists (Columns) on a Board
UpdateListAsync Update a List
MoveListToBoardAsync Move an entire list to another board
ArchiveListAsync Archive a List
ReOpenListAsync Reopen a List (Send back to the board)

Member Features

Members are the users of Trello, and via the API you can manage invites and access to Boards and Organizations, as well as the assignment of them to Cards

Feature Description
AddMembersToCardAsync Add one or more Members to a Card
AddMemberToBoardAsync Add a Member to a board (aka give them access)
GetMemberAsync Get a Member with a specific Id
GetMembersOfCardAsync Get the Members (users) of a Card
GetMembersOfBoardAsync Get the Members (users) of a board
GetMembersOfOrganizationAsync Get the Members (users) of an Organization
RemoveMembersFromCardAsync Remove a Member of a Card
RemoveAllMembersFromCardAsync Remove all Members of a Card
RemoveMemberFromBoardAsync Remove a Member from a board (aka revoke access)
InviteMemberToBoardViaEmailAsync Invite a Member to a board via email (aka give them access)
GetTokenMemberAsync Get information about the Member that owns the token used by this TrelloClient
AddVoteToCardAsync Add a Vote from a member to a card
RemoveVoteFromCardAsync Remove a Member Vote from a card
GetMembersWhoVotedOnCardAsync Get a list of Members who have voted for a Card

Membership Features

Memberships are information about a Member access to a thing (Example: if the Member is Admin or Normal User on a Board). Via the API you can get and update the memberships

Feature Description
GetMembershipsOfBoardAsync The Membership Information for a board (aka if Users are Admin, Normal, or Observer)
UpdateMembershipTypeOfMemberOnBoardAsync Change the membership type of a member Member on a board (Example make them Admin)

Organization Features

Organizations are in Trello called Workspaces but in the API the Organization name is kept to better align with official documentation. The API provides basic CRUD operations

Feature Description
AddOrganizationAsync Create a new Organization (Workspace)
GetOrganizationAsync Get an Organization (also known as Workspace)
GetOrganizationsForMemberAsync Get the Organizations that the specified member has access to
GetOrganizationsCurrentTokenCanAccessAsync Get the Organizations that the token provided to the TrelloClient can Access
UpdateOrganizationAsync Update an Organization (Workspace)
DeleteOrganizationAsync Delete an entire Organization including all Boards it contains

PluginData Features

PluginData are in Trello data from PowerUps that are bound to cards or boards

Feature Description
GetPluginDataOnCardAsync Get PluginData on a Card
GetPluginDataOfBoardAsync Get PluginData of a Board

Search Features

Search makes it possible to search Organizations, Boards, Cards and Members.

Feature Description
SearchAsync Search Trello for Cards, Boards, and/or Organizations
SearchMembersAsync Search for Trello members.

Sticker Features

Stickers are visuals you can 'attach' at the top of Cards to indicate something special (for example a warning sticker about something is wrong with the card) or someone did a good/bad job with a thumbs-up/thumbs-down sticker. The API provides operations to add and remove stickers to cards.

Feature Description
AddStickerToCardAsync Add a sticker to a card
GetStickerAsync Get a Stickers with a specific Id
GetStickersOnCardAsync Get List of Stickers on a card
UpdateStickerAsync Update a sticker
DeleteStickerAsync Delete a sticker

Webhook Features

Trello has the option to create Webhooks that can, on each Action event you users do on a board, send the information to a Callback URL. The raw API provides CRUD operations for managing these Webhook subscriptions. For the reaction of event see the Automation Engine system [recommended] and/or the Webhook Data Receiver

Feature Description
AddWebhookAsync Add a new Webhook
GetWebhooksForCurrentTokenAsync Get Webhooks linked with the current Token used to authenticate with the API
GetWebhookAsync Get a Webhook from its Id
UpdateWebhookAsync Update a webhook
UpdateWebhookByCallbackUrlAsync Replace callback URL for one or more Webhooks
DeleteWebhookAsync Delete a Webhook
DeleteWebhooksByCallbackUrlAsync Delete Webhooks using indicated Callback URL
DeleteWebhooksByTargetModelIdAsync Delete Webhooks using indicated target ModelId

Clone this wiki locally