{
  "openapi": "3.1.0",
  "info": {
    "title": "Nimbli API",
    "version": "v1",
    "description": "Nimbli's API for scripts: your teams' short links, made, listed, searched, read, changed and deleted, and their clicks per day. Make a token on the Developers page and send it as `Authorization: Bearer <token>`. A link belongs to a team: `listTeams` gives each team's `id`. Clicks are estimates: bots, previews and link checkers aren't counted."
  },
  "servers": [
    {
      "url": "https://nimbli.app/api/v1"
    }
  ],
  "paths": {
    "/listTeams": {
      "post": {
        "operationId": "listTeams",
        "summary": "The teams you're in, by name. Pass a team's `id` as `team` to make or list its links.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [],
                "additionalProperties": false,
                "properties": {
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100,
                    "default": 50
                  },
                  "after": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              },
              "example": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "A page of rows, and `next` for the one after, null at the end",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name"
                        ],
                        "properties": {
                          "id": {
                            "type": "string",
                            "pattern": "^team_"
                          },
                          "name": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "next": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "team_01JB8XQ2F4ZK7M3N9P5R2T6V8W",
                      "name": "name"
                    }
                  ],
                  "next": "next"
                }
              }
            }
          },
          "400": {
            "description": "bad request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "not found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "too many requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "internal server error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "service unavailable",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/createLink": {
      "post": {
        "operationId": "createLink",
        "summary": "Makes a short link in a team, with a random 7-character code, and optionally a short link name (3 to 50 of a-z 0-9 - _) and a note. The destination must be an https address that isn't an IP address, a Nimbli link, another link shortener or blocked. A team makes at most 25 links, 20 an hour and 100 a day (10 a day in its first week). Send an `Idempotency-Key` header to retry safely.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            },
            "description": "A retry with the same key and body gets the first answer, for 24 hours"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "team",
                  "destination"
                ],
                "additionalProperties": false,
                "properties": {
                  "team": {
                    "type": "string",
                    "pattern": "^team_"
                  },
                  "destination": {
                    "type": "string"
                  },
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "default": {
                      "expression": "null"
                    }
                  },
                  "note": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "minLength": 0,
                    "maxLength": 100,
                    "default": {
                      "expression": "null"
                    }
                  }
                }
              },
              "example": {
                "team": "team_01JB8XQ2F4ZK7M3N9P5R2T6V8W",
                "destination": "destination",
                "name": "name",
                "note": "note"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The answer",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "code",
                    "name",
                    "destination",
                    "note",
                    "state",
                    "createdAt",
                    "changedAt"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "pattern": "^link_"
                    },
                    "code": {
                      "type": "string"
                    },
                    "name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "destination": {
                      "type": "string",
                      "format": "uri"
                    },
                    "note": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "state": {
                      "type": "string",
                      "enum": [
                        "active",
                        "flagged",
                        "disabled"
                      ]
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "changedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    }
                  }
                },
                "example": {
                  "id": "link_01JB8XQ2F4ZK7M3N9P5R2T6V8W",
                  "code": "code",
                  "name": "name",
                  "destination": "https://example.com/page",
                  "note": "note",
                  "state": "active",
                  "createdAt": "2030-01-15T09:30:00.000Z",
                  "changedAt": "2030-01-15T09:30:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "bad request; `code` may be `blocked_destination`, `invalid_destination`, `invalid_name`, `invalid_note`, `private_destination`, `reserved_name`, `shortener_destination`, `unsafe_destination`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "not found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "conflict; `code` may be `name_taken`, `team_full`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "too many requests; `code` may be `limit_reached`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "internal server error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "service unavailable; `code` may be `check_unavailable`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/createLinks": {
      "post": {
        "operationId": "createLinks",
        "summary": "Makes up to 50 links in a team at once. Each gets its own result: the link, or the status and message `createLink` would have failed with. One failing doesn't stop the others.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            },
            "description": "A retry with the same key and body gets the first answer, for 24 hours"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "team",
                  "links"
                ],
                "additionalProperties": false,
                "properties": {
                  "team": {
                    "type": "string",
                    "pattern": "^team_"
                  },
                  "links": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "destination"
                      ],
                      "additionalProperties": false,
                      "properties": {
                        "destination": {
                          "type": "string"
                        },
                        "name": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "note": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      }
                    }
                  }
                }
              },
              "example": {
                "team": "team_01JB8XQ2F4ZK7M3N9P5R2T6V8W",
                "links": [
                  {
                    "destination": "destination",
                    "name": "name",
                    "note": "note"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The answer",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "results"
                  ],
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "link",
                          "status",
                          "code",
                          "message"
                        ],
                        "properties": {
                          "link": {
                            "type": [
                              "object",
                              "null"
                            ],
                            "required": [
                              "id",
                              "code",
                              "name",
                              "destination",
                              "note",
                              "state",
                              "createdAt",
                              "changedAt"
                            ],
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^link_"
                              },
                              "code": {
                                "type": "string"
                              },
                              "name": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "destination": {
                                "type": "string",
                                "format": "uri"
                              },
                              "note": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "state": {
                                "type": "string",
                                "enum": [
                                  "active",
                                  "flagged",
                                  "disabled"
                                ]
                              },
                              "createdAt": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "changedAt": {
                                "type": [
                                  "string",
                                  "null"
                                ],
                                "format": "date-time"
                              }
                            }
                          },
                          "status": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "code": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "message": {
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "results": [
                    {
                      "link": {
                        "id": "link_01JB8XQ2F4ZK7M3N9P5R2T6V8W",
                        "code": "code",
                        "name": "name",
                        "destination": "https://example.com/page",
                        "note": "note",
                        "state": "active",
                        "createdAt": "2030-01-15T09:30:00.000Z",
                        "changedAt": "2030-01-15T09:30:00.000Z"
                      },
                      "status": 3,
                      "code": "code",
                      "message": "message"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "bad request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "not found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "too many requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "internal server error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "service unavailable",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/listLinks": {
      "post": {
        "operationId": "listLinks",
        "summary": "A team's links, newest first, deleted ones left out. `state` keeps only active, flagged or disabled links; `q` matches the code, short link name, destination or note.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "team"
                ],
                "additionalProperties": false,
                "properties": {
                  "team": {
                    "type": "string",
                    "pattern": "^team_"
                  },
                  "state": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "enum": [
                      "active",
                      "flagged",
                      "disabled",
                      null
                    ],
                    "default": {
                      "expression": "null"
                    }
                  },
                  "q": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "default": {
                      "expression": "null"
                    }
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100,
                    "default": 50
                  },
                  "after": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              },
              "example": {
                "team": "team_01JB8XQ2F4ZK7M3N9P5R2T6V8W",
                "state": "active",
                "q": "q"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A page of rows, and `next` for the one after, null at the end",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "code",
                          "name",
                          "destination",
                          "note",
                          "state",
                          "createdAt",
                          "changedAt"
                        ],
                        "properties": {
                          "id": {
                            "type": "string",
                            "pattern": "^link_"
                          },
                          "code": {
                            "type": "string"
                          },
                          "name": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "destination": {
                            "type": "string",
                            "format": "uri"
                          },
                          "note": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "state": {
                            "type": "string",
                            "enum": [
                              "active",
                              "flagged",
                              "disabled"
                            ]
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "changedAt": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          }
                        }
                      }
                    },
                    "next": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "link_01JB8XQ2F4ZK7M3N9P5R2T6V8W",
                      "code": "code",
                      "name": "name",
                      "destination": "https://example.com/page",
                      "note": "note",
                      "state": "active",
                      "createdAt": "2030-01-15T09:30:00.000Z",
                      "changedAt": "2030-01-15T09:30:00.000Z"
                    }
                  ],
                  "next": "next"
                }
              }
            }
          },
          "400": {
            "description": "bad request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "not found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "too many requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "internal server error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "service unavailable",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/getLink": {
      "post": {
        "operationId": "getLink",
        "summary": "One link by its code. A deleted link, or one outside your teams, is 404.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "code"
                ],
                "additionalProperties": false,
                "properties": {
                  "code": {
                    "type": "string",
                    "minLength": 7,
                    "maxLength": 7
                  }
                }
              },
              "example": {
                "code": "codexxx"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The answer",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "code",
                    "name",
                    "destination",
                    "note",
                    "state",
                    "createdAt",
                    "changedAt"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "pattern": "^link_"
                    },
                    "code": {
                      "type": "string"
                    },
                    "name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "destination": {
                      "type": "string",
                      "format": "uri"
                    },
                    "note": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "state": {
                      "type": "string",
                      "enum": [
                        "active",
                        "flagged",
                        "disabled"
                      ]
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "changedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    }
                  }
                },
                "example": {
                  "id": "link_01JB8XQ2F4ZK7M3N9P5R2T6V8W",
                  "code": "code",
                  "name": "name",
                  "destination": "https://example.com/page",
                  "note": "note",
                  "state": "active",
                  "createdAt": "2030-01-15T09:30:00.000Z",
                  "changedAt": "2030-01-15T09:30:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "bad request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "not found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "too many requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "internal server error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "service unavailable",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/setDestination": {
      "post": {
        "operationId": "setDestination",
        "summary": "Changes where a link goes. Printed QR codes and shared links follow. A flagged or disabled link can't change.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            },
            "description": "A retry with the same key and body gets the first answer, for 24 hours"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "code",
                  "destination"
                ],
                "additionalProperties": false,
                "properties": {
                  "code": {
                    "type": "string",
                    "minLength": 7,
                    "maxLength": 7
                  },
                  "destination": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "code": "codexxx",
                "destination": "destination"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The answer",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "code",
                    "name",
                    "destination",
                    "note",
                    "state",
                    "createdAt",
                    "changedAt"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "pattern": "^link_"
                    },
                    "code": {
                      "type": "string"
                    },
                    "name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "destination": {
                      "type": "string",
                      "format": "uri"
                    },
                    "note": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "state": {
                      "type": "string",
                      "enum": [
                        "active",
                        "flagged",
                        "disabled"
                      ]
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "changedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    }
                  }
                },
                "example": {
                  "id": "link_01JB8XQ2F4ZK7M3N9P5R2T6V8W",
                  "code": "code",
                  "name": "name",
                  "destination": "https://example.com/page",
                  "note": "note",
                  "state": "active",
                  "createdAt": "2030-01-15T09:30:00.000Z",
                  "changedAt": "2030-01-15T09:30:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "bad request; `code` may be `blocked_destination`, `invalid_destination`, `private_destination`, `shortener_destination`, `unsafe_destination`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "not found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "conflict; `code` may be `link_disabled`, `link_flagged`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "too many requests; `code` may be `limit_reached`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "internal server error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "service unavailable; `code` may be `check_unavailable`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/setNote": {
      "post": {
        "operationId": "setNote",
        "summary": "Sets a link's note to self, or clears it with null.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            },
            "description": "A retry with the same key and body gets the first answer, for 24 hours"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "code",
                  "note"
                ],
                "additionalProperties": false,
                "properties": {
                  "code": {
                    "type": "string",
                    "minLength": 7,
                    "maxLength": 7
                  },
                  "note": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "minLength": 0,
                    "maxLength": 100
                  }
                }
              },
              "example": {
                "code": "codexxx",
                "note": "note"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The answer",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "code",
                    "name",
                    "destination",
                    "note",
                    "state",
                    "createdAt",
                    "changedAt"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "pattern": "^link_"
                    },
                    "code": {
                      "type": "string"
                    },
                    "name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "destination": {
                      "type": "string",
                      "format": "uri"
                    },
                    "note": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "state": {
                      "type": "string",
                      "enum": [
                        "active",
                        "flagged",
                        "disabled"
                      ]
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "changedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    }
                  }
                },
                "example": {
                  "id": "link_01JB8XQ2F4ZK7M3N9P5R2T6V8W",
                  "code": "code",
                  "name": "name",
                  "destination": "https://example.com/page",
                  "note": "note",
                  "state": "active",
                  "createdAt": "2030-01-15T09:30:00.000Z",
                  "changedAt": "2030-01-15T09:30:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "bad request; `code` may be `invalid_note`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "not found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "too many requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "internal server error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "service unavailable",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/renameLink": {
      "post": {
        "operationId": "renameLink",
        "summary": "Sets, changes or removes (null) a link's short link name. The old name stops working at once and stays your team's; QR codes keep working, since they use the code.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            },
            "description": "A retry with the same key and body gets the first answer, for 24 hours"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "code",
                  "name"
                ],
                "additionalProperties": false,
                "properties": {
                  "code": {
                    "type": "string",
                    "minLength": 7,
                    "maxLength": 7
                  },
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              },
              "example": {
                "code": "codexxx",
                "name": "name"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The answer",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "code",
                    "name",
                    "destination",
                    "note",
                    "state",
                    "createdAt",
                    "changedAt"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "pattern": "^link_"
                    },
                    "code": {
                      "type": "string"
                    },
                    "name": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "destination": {
                      "type": "string",
                      "format": "uri"
                    },
                    "note": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "state": {
                      "type": "string",
                      "enum": [
                        "active",
                        "flagged",
                        "disabled"
                      ]
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "changedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    }
                  }
                },
                "example": {
                  "id": "link_01JB8XQ2F4ZK7M3N9P5R2T6V8W",
                  "code": "code",
                  "name": "name",
                  "destination": "https://example.com/page",
                  "note": "note",
                  "state": "active",
                  "createdAt": "2030-01-15T09:30:00.000Z",
                  "changedAt": "2030-01-15T09:30:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "bad request; `code` may be `invalid_name`, `reserved_name`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "not found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "conflict; `code` may be `link_disabled`, `link_flagged`, `name_taken`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "too many requests; `code` may be `limit_reached`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "internal server error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "service unavailable",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/deleteLink": {
      "post": {
        "operationId": "deleteLink",
        "summary": "Deletes a link: it answers \"link not found\" at once, and its code and name are never used again.",
        "security": [
          {
            "token": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            },
            "description": "A retry with the same key and body gets the first answer, for 24 hours"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "code"
                ],
                "additionalProperties": false,
                "properties": {
                  "code": {
                    "type": "string",
                    "minLength": 7,
                    "maxLength": 7
                  }
                }
              },
              "example": {
                "code": "codexxx"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The answer",
            "content": {
              "application/json": {
                "schema": {
                  "type": "null"
                },
                "example": null
              }
            }
          },
          "400": {
            "description": "bad request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "not found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "too many requests; `code` may be `limit_reached`",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "internal server error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "service unavailable",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/linkClicks": {
      "post": {
        "operationId": "linkClicks",
        "summary": "A link's clicks per day for the last 30 days, oldest first, with the totals for 7 and 30 days.",
        "security": [
          {
            "token": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "code"
                ],
                "additionalProperties": false,
                "properties": {
                  "code": {
                    "type": "string",
                    "minLength": 7,
                    "maxLength": 7
                  }
                }
              },
              "example": {
                "code": "codexxx"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The answer",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "days",
                    "last7",
                    "last30"
                  ],
                  "properties": {
                    "days": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "date",
                          "clicks"
                        ],
                        "properties": {
                          "date": {
                            "type": "string",
                            "format": "date"
                          },
                          "clicks": {
                            "type": "integer"
                          }
                        }
                      }
                    },
                    "last7": {
                      "type": "integer"
                    },
                    "last30": {
                      "type": "integer"
                    }
                  }
                },
                "example": {
                  "days": [
                    {
                      "date": "2030-01-15",
                      "clicks": 3
                    }
                  ],
                  "last7": 3,
                  "last30": 3
                }
              }
            }
          },
          "400": {
            "description": "bad request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "not found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "too many requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "internal server error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "service unavailable",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "token": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API token from the app's agents page"
      }
    },
    "schemas": {
      "Problem": {
        "type": "object",
        "required": [
          "type",
          "status",
          "code",
          "detail",
          "errors"
        ],
        "properties": {
          "type": {
            "type": "string",
            "format": "uri"
          },
          "status": {
            "type": "integer"
          },
          "code": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "detail"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "detail": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}