Skip to content
Docs
About By Dawn Contact supportOpen By Dawn
  1. Work with tickets
  2. Update and move a ticket

Update and move a ticket

Use this to keep a ticket in step with the world outside By Dawn: raise its priority when an alert gets worse, add what you’ve learned to its description, or move it along the board. By the end the ticket will show your changes, and nothing else about it will have changed.

Before you start: you need a Board — read & write key (see Scopes) and the ticket’s id, for example from Create a ticket. Pass the ID as the recipe’s argument.

Read down the steps. The code on the right follows along and highlights the lines each one explains.

  1. Every recipe starts this way, as the Quickstart explains.

    // 1. Exchange the API key for a short-lived access token. Every call after this goes to your
    // organization's URL with the token as a Bearer header.
    const exchange: Schemas['ApiKeyExchange'] = { apiKey };
    const { accessToken: token } = await call<Schemas['AccessTokenData']['data']>(`${ACCOUNTS_URL}/auth/token/api-key`, { method: 'POST', body: exchange });
    const api = `${WORKSPACE_URL}/orgs/${orgIdOf(token)}`;
  2. The recipe reads the ticket first, so it can show what changed, and so it can add to the description rather than replace it.

    // 2. Read the ticket you named as it is now, so the output can show what changed.
    const ticketId = process.argv[2];
    if (!ticketId) throw new Error('Usage: node update-ticket.ts <ticketId>');
    const url = `${api}/tickets/${encodeURIComponent(ticketId)}`;
    const before = await call<Schemas['Ticket']>(url, { token });
  3. PATCH /tickets/{ticketId} changes only the fields you send, and leaves the rest alone. So you don’t need to read a ticket before every update, only when the new value depends on the old one, as the description does here.

    // 3. Send only the fields you want to change.
    // Sending `statusId` moves the ticket to another board column. A move into a column with the
    // `building` role would start an agent run, so the API refuses it for an API key.
    const update: Schemas['TicketUpdate'] = {
    title: 'Updated by the update-ticket recipe',
    priority: 'HIGH',
    description: `${before.description ?? ''}\n\nUpdated through the SAW API.`.trim(),
    };
    const ticket = await call<Schemas['Ticket']>(url, { method: 'PATCH', body: update, token });
    console.log(`${ticket.identifier}: "${before.title}" → "${ticket.title}", priority ${before.priority} → ${ticket.priority}`);

Run the TypeScript recipe from this page. It changes the ticket’s title, priority and description. A ticket you created here is filled in for you. See Try it in your browser.

Try it with your organization

How this works

Connect once and run this recipe live against the By Dawn API.

Your key stays in this tab and goes only to By Dawn. Use a read-only key in a test organization.

▶ Run update-ticket.tsThe same code CI runs, in your browser

This recipe updates the ticket in your organization.

Connect your organization above to run it.
  • Lists are replaced, not merged. labelIds and repoIds replace the whole list, so to add a label, send the IDs it already has plus the new one.
  • Leave out, null or a value. For fields like cycleId and estimate, leaving the field out keeps it, null clears it, and a value sets it.
  • Moving between columns. Send a new statusId to move the ticket. The one move a key can’t make is into the column that starts By Dawn’s agent (see what a key can’t do).
  • Archiving. POST /tickets/{ticketId}/archive takes a ticket off the board, and /unarchive brings it back.