Berner Setterwall3 min read

    Ship Code Tickets From the Cogny CLI: Create, Approve, Get the Pull Request

    Until this week, an agent working with the Cogny CLI could read your tickets but couldn't take a website change all the way. It could write the ticket as a plain task, and then a person had to open the app, turn it into a code ticket and press Approve.

    Now the whole loop works from the command line or any MCP client:

    1. create_ticket with execution_target: "code" writes a code ticket. If the workspace has more than one repository connected, name it with repo.
    2. approve_ticket starts Cogny's code agent, exactly as the Approve button does. The agent reads the repository, makes the change and opens a pull request.
    3. get_ticket returns the run's status and, when it finishes, the pull request URL, or the error if it failed.
    export COGNY_API_KEY=cogny_…   # a workspace API key
    
    cogny tools call create_ticket --input '{
      "title": "Add an FAQ section to the pricing page",
      "body": "Five questions from support, with FAQPage schema …",
      "execution_target": "code"
    }'
    
    cogny tools call approve_ticket --input '{"ticket_id": "<id>"}'
    
    cogny tools call get_ticket --input '{"ticket_id": "<id>", "wait_seconds": 25}'
    # latest_run: { status: "completed", pr_url: "https://github.com/…/pull/123", … }
    

    From there it's the usual Cogny Sites loop: a preview deploy for the pull request, a visual check of the rendered page, your review, the merge, and a measurement of what the change did.

    Waiting for the result

    A code run takes a few minutes. There are two ways to wait for it:

    • Any client: call get_ticket with wait_seconds (up to 25). It returns as soon as the run moves on, or after the wait, with a one-line summary of where it is.
    • Clients that support MCP Tasks: approve_ticket runs as a task. The client gets a task id straight away, and the task finishes with the pull request URL, or as an error with the reason. If the client can ask the user a question, it asks them to confirm the approval first. Cancelling the task stops the wait, not the code agent.

    Who the approval is recorded as

    A workspace API key belongs to the workspace, not to a person, but an approval spends credits and starts work, so Cogny records it as one. An approval made with a key counts as approved by the member who created the key. If that member has left the workspace, or the key is older than this record, it counts as the workspace owner's. The ticket's history and the board both say the approval came through a workspace API key.

    Everything else stays the same as pressing Approve in the app: approving spends the workspace's credits and is refused when none are left (cogny_status shows the balance), and a pull request merges only when a person merges it, or when an owner or admin has turned on auto-merge and it passes every check.

    Clear refusals

    When something is missing, the tool says what to fix instead of creating a ticket that can never run:

    • no repository connected: connect one in Settings → Coding Agent;
    • several repositories and none named: pass repo;
    • a repo that isn't connected to this workspace: the tool names the ones that are;
    • no credits left: top up, or wait for the monthly allowance.

    Refusals now come back to the client as errors, so a script can stop on them instead of reading a success message that says no.

    Who can use it

    Code tickets need a Cloud workspace with a GitHub or Forgejo repository connected. They work over the Cogny connector in Claude, ChatGPT or Cursor (signed in as you) and with a workspace API key in the Cogny CLI. On Free, Solo, Cogny AI and Cogny Pro, create_ticket doesn't offer code tickets.

    The full tool list is in the MCP docs, and the code agent itself in the coding agent and Cogny Sites.