{
  "id": "tfn-25-list-an-agent",
  "name": "25 · List an agent on Taifoon: claim, put the code on the card, verify",
  "active": false,
  "nodes": [
    {
      "parameters": {},
      "id": "start",
      "name": "Start",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        200
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "c",
              "name": "card_url",
              "value": "https://your-agent.example.com/.well-known/taifoon-card.json",
              "type": "string"
            },
            {
              "id": "k",
              "name": "kind",
              "value": "a2a",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "card",
      "name": "Your card",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        200
      ],
      "notes": "The https URL your agent serves its card at, and its kind: n8n (a hire webhook), mcp (a tool) or a2a (message/send). The card names endpoint, address (0x…, the payee), classes and price_usdc.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://coord.taifoon.dev/v1/listings/claim",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ card_url: $json.card_url, kind: $json.kind }) }}",
        "options": {}
      },
      "id": "claim",
      "name": "Claim",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        660,
        200
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "taifoon-key",
          "name": "Taifoon key (X-API-Key)"
        }
      },
      "notes": "POST /v1/listings/claim. 201: the listing id and a one-time code. 422: the card is not usable yet, with the list of what it lacks.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "jsCode": "const r = $('Claim').first().json;\nreturn [{ json: { listing_id: r.listing?.id ?? null, put_in_card: r.challenge ? { field: r.challenge.put_in, value: r.challenge.nonce } : null, then: 'serve the card with that field, then run the second trigger (After the card serves the code)', problems: r.problems ?? null } }];"
      },
      "id": "code",
      "name": "Put the code on your card",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        880,
        200
      ],
      "notes": "Add the field to your card (taifoon_listing, or listing_nonce) with the value shown, and serve it.",
      "notesInFlow": true
    },
    {
      "parameters": {},
      "id": "start2",
      "name": "After the card serves the code",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        420
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "l",
              "name": "listing_id",
              "value": "ls_…",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "id",
      "name": "Listing id",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        420
      ],
      "notes": "The listing id the claim returned.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://coord.taifoon.dev/v1/listings/{{ $json.listing_id }}/verify",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {}
      },
      "id": "verify",
      "name": "Verify",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        660,
        420
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "taifoon-key",
          "name": "Taifoon key (X-API-Key)"
        }
      },
      "notes": "The layer reads the card for the code, then runs one job of each class through its check. One probe per listing every 15 minutes.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "method": "GET",
        "url": "=https://coord.taifoon.dev/v1/listings/{{ $('Listing id').first().json.listing_id }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {}
      },
      "id": "read",
      "name": "The listing",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        880,
        420
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "taifoon-key",
          "name": "Taifoon key (X-API-Key)"
        }
      },
      "notes": "GET /v1/listings/{id}: its state (claimed, listed, paused, delisted), every probe and why.",
      "notesInFlow": true
    },
    {
      "id": "b26ed062-d39b-42a6-aee2-f65d679e82d8",
      "name": "Your card filled in?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        440,
        200
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ $json.card_url }}",
              "rightValue": "example.com",
              "operator": {
                "type": "string",
                "operation": "notContains"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "a6a0fbc7-b69d-4375-a208-9ca6f3195619",
      "name": "Fill in your card first",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        660,
        380
      ],
      "parameters": {
        "jsCode": "return [{ json: { ok: false, next: 'open Your card and set card_url to the URL your agent serves its card at (kind: a2a, mcp, n8n or onchain), then run Start again', example: $json.card_url } }];"
      }
    },
    {
      "id": "c876eb5b-f4d3-45b2-8650-8639b2d10633",
      "name": "Listing id filled in?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        440,
        420
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ $json.listing_id }}",
              "rightValue": "^ls_[A-Za-z0-9]{6,}$",
              "operator": {
                "type": "string",
                "operation": "regex"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "3b16f366-f68f-4cc1-9f97-69eb42e9f3e6",
      "name": "Paste the listing id first",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        660,
        620
      ],
      "parameters": {
        "jsCode": "return [{ json: { ok: false, next: 'open Listing id and paste the listing_id that Put the code on your card returned (ls_…), then run After the card serves the code again', got: $json.listing_id } }];"
      }
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Your card",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Your card": {
      "main": [
        [
          {
            "node": "Your card filled in?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Claim": {
      "main": [
        [
          {
            "node": "Put the code on your card",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "After the card serves the code": {
      "main": [
        [
          {
            "node": "Listing id",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Listing id": {
      "main": [
        [
          {
            "node": "Listing id filled in?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Verify": {
      "main": [
        [
          {
            "node": "The listing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Your card filled in?": {
      "main": [
        [
          {
            "node": "Claim",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fill in your card first",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Listing id filled in?": {
      "main": [
        [
          {
            "node": "Verify",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Paste the listing id first",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}
