{
  "openapi": "3.1.0",
  "info": {
    "title": "Sendly EHF API",
    "version": "1.0.0",
    "description": "Send and receive EHF 3 / Peppol BIS Billing 3.0 invoices with JSON. Test keys (sk_test_) never send anything; org.nr 999999999 is always delivered, 111111111 always fails, 222222222 is not on Peppol. Every endpoint except POST /signup requires an API key; lookup, validate and render are free."
  },
  "servers": [
    {
      "url": "https://sendly.no/v1"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "paths": {
    "/signup": {
      "post": {
        "summary": "Create account and get a test key",
        "tags": [
          "Account"
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Object"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Signup"
              }
            }
          }
        },
        "security": []
      }
    },
    "/companies": {
      "get": {
        "summary": "Search Brønnøysundregistrene by company name or organisation number",
        "description": "Free (not billed), API key required. A 9-digit q returns that unit; anything else is a name search ranked by match quality and company size.",
        "tags": [
          "Tools"
        ],
        "parameters": [
          {
            "in": "query",
            "name": "q",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 2
            },
            "description": "Company name (or part of it) or a 9-digit organisation number"
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 20,
              "default": 8
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": [
                        "list"
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CompanyHit"
                      }
                    }
                  }
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/lookup/{id}": {
      "get": {
        "summary": "Look up a recipient (Peppol capability + Brønnøysund)",
        "tags": [
          "Tools"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Recipient"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/validate": {
      "post": {
        "summary": "Validate EHF/UBL XML",
        "tags": [
          "Tools"
        ],
        "requestBody": {
          "content": {
            "application/xml": {
              "schema": {
                "type": "string"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationResult"
                }
              }
            }
          }
        }
      }
    },
    "/render": {
      "post": {
        "summary": "Render EHF/UBL XML as PDF",
        "tags": [
          "Tools"
        ],
        "requestBody": {
          "content": {
            "application/xml": {
              "schema": {
                "type": "string"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "File",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/organizations": {
      "post": {
        "summary": "Register a sender organization",
        "tags": [
          "Organizations"
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Organization"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrganizationInput"
              }
            }
          }
        }
      },
      "get": {
        "summary": "List organizations",
        "tags": [
          "Organizations"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/List"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/organizations/{id}": {
      "get": {
        "summary": "Get organization",
        "tags": [
          "Organizations"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Organization"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "patch": {
        "summary": "Update organization",
        "tags": [
          "Organizations"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Organization"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrganizationInput"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/invoices": {
      "post": {
        "summary": "Create and send an invoice",
        "tags": [
          "Invoices"
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceInput"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "description": "Safe retries: the same key + body returns the same document."
          }
        ]
      },
      "get": {
        "summary": "List invoices",
        "tags": [
          "Invoices"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/List"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "processing|sent|delivered|failed"
          },
          {
            "name": "number",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": ""
          },
          {
            "name": "buyer",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Buyer org.nr"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "1-100"
          },
          {
            "name": "starting_after",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Cursor"
          }
        ]
      }
    },
    "/invoices/{id}": {
      "get": {
        "summary": "Get invoice",
        "tags": [
          "Invoices"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/invoices/{id}/xml": {
      "get": {
        "summary": "Download EHF XML",
        "tags": [
          "Invoices"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "File",
            "content": {
              "application/xml": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/invoices/{id}/pdf": {
      "get": {
        "summary": "Download PDF",
        "tags": [
          "Invoices"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "File",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/credit-notes": {
      "post": {
        "summary": "Create and send a credit note",
        "tags": [
          "Credit notes"
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreditNoteInput"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "description": "Safe retries: the same key + body returns the same document."
          }
        ]
      },
      "get": {
        "summary": "List credit notes",
        "tags": [
          "Credit notes"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/List"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/credit-notes/{id}": {
      "get": {
        "summary": "Get credit note",
        "tags": [
          "Credit notes"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/credit-notes/{id}/xml": {
      "get": {
        "summary": "Download EHF XML",
        "tags": [
          "Credit notes"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "File",
            "content": {
              "application/xml": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/credit-notes/{id}/pdf": {
      "get": {
        "summary": "Download PDF",
        "tags": [
          "Credit notes"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "File",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/attachments": {
      "post": {
        "summary": "Upload attachment (base64)",
        "tags": [
          "Attachments"
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Object"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AttachmentInput"
              }
            }
          }
        }
      }
    },
    "/attachments/{id}": {
      "get": {
        "summary": "Get attachment metadata",
        "tags": [
          "Attachments"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Object"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "delete": {
        "summary": "Delete attachment",
        "tags": [
          "Attachments"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Object"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/received": {
      "get": {
        "summary": "List received documents",
        "tags": [
          "Receiving"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/List"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/received/{id}": {
      "get": {
        "summary": "Get received document as JSON",
        "tags": [
          "Receiving"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Object"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/received/{id}/xml": {
      "get": {
        "summary": "Download received EHF",
        "tags": [
          "Receiving"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "File",
            "content": {
              "application/xml": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/received/{id}/pdf": {
      "get": {
        "summary": "Received document as PDF",
        "tags": [
          "Receiving"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "File",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/sandbox/receive": {
      "post": {
        "summary": "Simulate an inbound invoice (test mode)",
        "tags": [
          "Receiving"
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Object"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/webhook-endpoints": {
      "post": {
        "summary": "Create webhook endpoint",
        "tags": [
          "Webhooks"
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Object"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookInput"
              }
            }
          }
        }
      },
      "get": {
        "summary": "List webhook endpoints",
        "tags": [
          "Webhooks"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/List"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/webhook-endpoints/{id}": {
      "delete": {
        "summary": "Delete webhook endpoint",
        "tags": [
          "Webhooks"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Object"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/webhook-endpoints/{id}/rotate-secret": {
      "post": {
        "summary": "Rotate signing secret",
        "tags": [
          "Webhooks"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Object"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/webhook-deliveries": {
      "get": {
        "summary": "List webhook deliveries",
        "tags": [
          "Webhooks"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/List"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/webhook-deliveries/{id}/retry": {
      "post": {
        "summary": "Retry a delivery",
        "tags": [
          "Webhooks"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Object"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/api-keys": {
      "get": {
        "summary": "List API keys",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/List"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Create API key",
        "tags": [
          "Account"
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Object"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api-keys/{id}": {
      "delete": {
        "summary": "Revoke API key",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Object"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/usage": {
      "get": {
        "summary": "Usage for a month",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Object"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "month",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "YYYY-MM"
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "sk_test_… or sk_live_…"
      }
    },
    "schemas": {
      "InvoiceInput": {
        "type": "object",
        "required": [
          "number",
          "buyer",
          "lines"
        ],
        "properties": {
          "sender": {
            "type": "string",
            "description": "org_… id or organisation number. Optional if the account has one organization."
          },
          "number": {
            "type": "string"
          },
          "issue_date": {
            "type": "string",
            "format": "date"
          },
          "currency": {
            "type": "string",
            "default": "NOK"
          },
          "buyer": {
            "type": "object",
            "properties": {
              "organization_number": {
                "type": "string"
              },
              "peppol_id": {
                "type": "object",
                "properties": {
                  "scheme": {
                    "type": "string"
                  },
                  "id": {
                    "type": "string"
                  }
                }
              },
              "name": {
                "type": "string"
              },
              "vat_number": {
                "type": "string"
              },
              "address": {
                "type": "object",
                "properties": {
                  "street": {
                    "type": "string"
                  },
                  "additional": {
                    "type": "string"
                  },
                  "city": {
                    "type": "string"
                  },
                  "postal_code": {
                    "type": "string"
                  },
                  "country": {
                    "type": "string",
                    "default": "NO"
                  }
                }
              },
              "contact": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  },
                  "phone": {
                    "type": "string"
                  }
                }
              },
              "email": {
                "type": "string",
                "description": "Used by fallback=email"
              }
            }
          },
          "buyer_reference": {
            "type": "string",
            "description": "Required unless order_reference is given"
          },
          "order_reference": {
            "type": "string"
          },
          "contract_reference": {
            "type": "string"
          },
          "accounting_cost": {
            "type": "string"
          },
          "delivery_date": {
            "type": "string",
            "format": "date"
          },
          "period": {
            "type": "object",
            "properties": {
              "start": {
                "type": "string",
                "format": "date"
              },
              "end": {
                "type": "string",
                "format": "date"
              }
            }
          },
          "note": {
            "type": "string"
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "description",
                "unit_price"
              ],
              "properties": {
                "description": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "quantity": {
                  "type": "number",
                  "default": 1
                },
                "unit": {
                  "type": "string",
                  "default": "stk",
                  "description": "stk, time, dag, mnd, kg, m, l … or UN/ECE Rec 20 code"
                },
                "unit_price": {
                  "type": "number",
                  "description": "Excl. VAT"
                },
                "vat_rate": {
                  "type": "number",
                  "default": 25
                },
                "vat_category": {
                  "type": "string",
                  "enum": [
                    "S",
                    "Z",
                    "E",
                    "AE",
                    "K",
                    "G",
                    "O",
                    "L",
                    "M"
                  ]
                },
                "discount": {
                  "type": "number"
                },
                "discount_percent": {
                  "type": "number"
                },
                "item_id": {
                  "type": "string"
                },
                "buyer_item_id": {
                  "type": "string"
                },
                "accounting_cost": {
                  "type": "string"
                },
                "period": {
                  "type": "object",
                  "properties": {
                    "start": {
                      "type": "string",
                      "format": "date"
                    },
                    "end": {
                      "type": "string",
                      "format": "date"
                    }
                  }
                }
              }
            },
            "minItems": 1
          },
          "allowances": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "reason",
                "amount"
              ],
              "properties": {
                "reason": {
                  "type": "string"
                },
                "amount": {
                  "type": "number"
                },
                "vat_rate": {
                  "type": "number"
                },
                "vat_category": {
                  "type": "string"
                }
              }
            }
          },
          "charges": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "reason",
                "amount"
              ],
              "properties": {
                "reason": {
                  "type": "string"
                },
                "amount": {
                  "type": "number"
                },
                "vat_rate": {
                  "type": "number"
                },
                "vat_category": {
                  "type": "string"
                }
              }
            }
          },
          "prepaid_amount": {
            "type": "number"
          },
          "attachment_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "attach_pdf": {
            "type": "boolean",
            "default": true
          },
          "fallback": {
            "type": "string",
            "enum": [
              "reject",
              "email"
            ],
            "default": "reject"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "dry_run": {
            "type": "boolean",
            "default": false
          },
          "due_date": {
            "type": "string",
            "format": "date"
          },
          "payment_terms_days": {
            "type": "integer"
          },
          "kid": {
            "type": "string"
          },
          "project_reference": {
            "type": "string"
          }
        }
      },
      "CreditNoteInput": {
        "type": "object",
        "required": [
          "number",
          "buyer",
          "lines",
          "credited_invoice"
        ],
        "properties": {
          "sender": {
            "type": "string",
            "description": "org_… id or organisation number. Optional if the account has one organization."
          },
          "number": {
            "type": "string"
          },
          "issue_date": {
            "type": "string",
            "format": "date"
          },
          "currency": {
            "type": "string",
            "default": "NOK"
          },
          "buyer": {
            "type": "object",
            "properties": {
              "organization_number": {
                "type": "string"
              },
              "peppol_id": {
                "type": "object",
                "properties": {
                  "scheme": {
                    "type": "string"
                  },
                  "id": {
                    "type": "string"
                  }
                }
              },
              "name": {
                "type": "string"
              },
              "vat_number": {
                "type": "string"
              },
              "address": {
                "type": "object",
                "properties": {
                  "street": {
                    "type": "string"
                  },
                  "additional": {
                    "type": "string"
                  },
                  "city": {
                    "type": "string"
                  },
                  "postal_code": {
                    "type": "string"
                  },
                  "country": {
                    "type": "string",
                    "default": "NO"
                  }
                }
              },
              "contact": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  },
                  "phone": {
                    "type": "string"
                  }
                }
              },
              "email": {
                "type": "string",
                "description": "Used by fallback=email"
              }
            }
          },
          "buyer_reference": {
            "type": "string",
            "description": "Required unless order_reference is given"
          },
          "order_reference": {
            "type": "string"
          },
          "contract_reference": {
            "type": "string"
          },
          "accounting_cost": {
            "type": "string"
          },
          "delivery_date": {
            "type": "string",
            "format": "date"
          },
          "period": {
            "type": "object",
            "properties": {
              "start": {
                "type": "string",
                "format": "date"
              },
              "end": {
                "type": "string",
                "format": "date"
              }
            }
          },
          "note": {
            "type": "string"
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "description",
                "unit_price"
              ],
              "properties": {
                "description": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "quantity": {
                  "type": "number",
                  "default": 1
                },
                "unit": {
                  "type": "string",
                  "default": "stk",
                  "description": "stk, time, dag, mnd, kg, m, l … or UN/ECE Rec 20 code"
                },
                "unit_price": {
                  "type": "number",
                  "description": "Excl. VAT"
                },
                "vat_rate": {
                  "type": "number",
                  "default": 25
                },
                "vat_category": {
                  "type": "string",
                  "enum": [
                    "S",
                    "Z",
                    "E",
                    "AE",
                    "K",
                    "G",
                    "O",
                    "L",
                    "M"
                  ]
                },
                "discount": {
                  "type": "number"
                },
                "discount_percent": {
                  "type": "number"
                },
                "item_id": {
                  "type": "string"
                },
                "buyer_item_id": {
                  "type": "string"
                },
                "accounting_cost": {
                  "type": "string"
                },
                "period": {
                  "type": "object",
                  "properties": {
                    "start": {
                      "type": "string",
                      "format": "date"
                    },
                    "end": {
                      "type": "string",
                      "format": "date"
                    }
                  }
                }
              }
            },
            "minItems": 1
          },
          "allowances": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "reason",
                "amount"
              ],
              "properties": {
                "reason": {
                  "type": "string"
                },
                "amount": {
                  "type": "number"
                },
                "vat_rate": {
                  "type": "number"
                },
                "vat_category": {
                  "type": "string"
                }
              }
            }
          },
          "charges": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "reason",
                "amount"
              ],
              "properties": {
                "reason": {
                  "type": "string"
                },
                "amount": {
                  "type": "number"
                },
                "vat_rate": {
                  "type": "number"
                },
                "vat_category": {
                  "type": "string"
                }
              }
            }
          },
          "prepaid_amount": {
            "type": "number"
          },
          "attachment_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "attach_pdf": {
            "type": "boolean",
            "default": true
          },
          "fallback": {
            "type": "string",
            "enum": [
              "reject",
              "email"
            ],
            "default": "reject"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "dry_run": {
            "type": "boolean",
            "default": false
          },
          "credited_invoice": {
            "type": "object",
            "required": [
              "number"
            ],
            "properties": {
              "number": {
                "type": "string"
              },
              "issue_date": {
                "type": "string",
                "format": "date"
              }
            }
          }
        }
      },
      "Document": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "enum": [
              "invoice",
              "credit_note"
            ]
          },
          "mode": {
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "processing",
              "sent",
              "delivered",
              "failed"
            ]
          },
          "number": {
            "type": "string"
          },
          "sender": {
            "type": "object"
          },
          "buyer": {
            "type": "object"
          },
          "issue_date": {
            "type": "string"
          },
          "due_date": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "totals": {
            "type": "object",
            "properties": {
              "line_extension": {
                "type": "number"
              },
              "allowances": {
                "type": "number"
              },
              "charges": {
                "type": "number"
              },
              "tax_exclusive": {
                "type": "number"
              },
              "vat": {
                "type": "number"
              },
              "tax_inclusive": {
                "type": "number"
              },
              "prepaid": {
                "type": "number"
              },
              "payable": {
                "type": "number"
              }
            }
          },
          "delivery": {
            "type": "object",
            "properties": {
              "channel": {
                "type": "string",
                "enum": [
                  "peppol",
                  "email"
                ]
              },
              "message_id": {
                "type": "string"
              },
              "sent_at": {
                "type": "string"
              },
              "delivered_at": {
                "type": "string"
              },
              "failed_at": {
                "type": "string"
              },
              "error": {
                "type": "string"
              },
              "email": {
                "type": "string"
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Issue"
            }
          },
          "metadata": {
            "type": "object"
          },
          "links": {
            "type": "object"
          },
          "created_at": {
            "type": "string"
          },
          "updated_at": {
            "type": "string"
          }
        }
      },
      "Object": {
        "type": "object"
      },
      "List": {
        "type": "object",
        "properties": {
          "object": {
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Issue": {
        "type": "object",
        "properties": {
          "rule": {
            "type": "string"
          },
          "severity": {
            "type": "string",
            "enum": [
              "error",
              "warning"
            ]
          },
          "path": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "message_no": {
            "type": "string"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "details": {},
              "request_id": {
                "type": "string"
              }
            }
          }
        }
      },
      "ValidationResult": {
        "type": "object",
        "properties": {
          "valid": {
            "type": "boolean"
          },
          "type": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Issue"
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Issue"
            }
          }
        }
      },
      "Recipient": {
        "type": "object",
        "properties": {
          "organization_number": {
            "type": "string"
          },
          "peppol_id": {
            "type": "string"
          },
          "valid": {
            "type": "boolean"
          },
          "company": {
            "type": [
              "object",
              "null"
            ]
          },
          "peppol": {
            "type": "object",
            "properties": {
              "registered": {
                "type": "boolean"
              },
              "can_receive_invoice": {
                "type": "boolean"
              },
              "can_receive_credit_note": {
                "type": "boolean"
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Signup": {
        "type": "object",
        "required": [
          "email"
        ],
        "properties": {
          "email": {
            "type": "string"
          },
          "company": {
            "type": "string"
          },
          "organization_number": {
            "type": "string"
          }
        }
      },
      "OrganizationInput": {
        "type": "object",
        "properties": {
          "organization_number": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "address": {
            "type": "object",
            "properties": {
              "street": {
                "type": "string"
              },
              "additional": {
                "type": "string"
              },
              "city": {
                "type": "string"
              },
              "postal_code": {
                "type": "string"
              },
              "country": {
                "type": "string",
                "default": "NO"
              }
            }
          },
          "vat_registered": {
            "type": "boolean"
          },
          "bank_account": {
            "type": "string"
          },
          "bic": {
            "type": "string"
          },
          "payment_terms_days": {
            "type": "integer"
          },
          "contact": {
            "type": "object"
          }
        }
      },
      "Organization": {
        "type": "object"
      },
      "AttachmentInput": {
        "type": "object",
        "required": [
          "filename",
          "content_type",
          "content"
        ],
        "properties": {
          "filename": {
            "type": "string"
          },
          "content_type": {
            "type": "string"
          },
          "content": {
            "type": "string",
            "contentEncoding": "base64"
          },
          "description": {
            "type": "string"
          }
        }
      },
      "WebhookInput": {
        "type": "object",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "description": {
            "type": "string"
          }
        }
      },
      "CompanyHit": {
        "type": "object",
        "required": [
          "organization_number",
          "name",
          "vat_registered",
          "bankrupt",
          "under_liquidation",
          "deleted"
        ],
        "properties": {
          "organization_number": {
            "type": "string",
            "example": "923609016"
          },
          "name": {
            "type": "string",
            "example": "EQUINOR ASA"
          },
          "org_form": {
            "type": "string",
            "example": "ASA"
          },
          "city": {
            "type": "string",
            "example": "STAVANGER"
          },
          "vat_registered": {
            "type": "boolean"
          },
          "bankrupt": {
            "type": "boolean"
          },
          "under_liquidation": {
            "type": "boolean"
          },
          "deleted": {
            "type": "boolean"
          }
        }
      }
    }
  }
}
