Skip to main content
REST client

Payables

The 2 operations under payables, as typed calls on the generated REST client.

1 min read
View MarkdownEdit on GitHub

Available from @codespar/sdk 0.12.0; the version on npm is 0.16.0. Every example on this page is compiled against the installed package when these docs build: a call that does not type-check fails the build.

Every call below is cs.api reaching one operation of the OpenAPI document this page was generated from; the REST client overview explains request, response, the option bag and the errors. The values are placeholders shaped by the document.

import {  } from "@codespar/sdk";

const  = new ({ : .. });

POST /v1/payables

Create a payable from a partner's record or a person's form

const r = await cs.api.response("post", "/v1/payables", {
  body: {
    schema_version: "payable.v1",
    doc_type: "invoice",
    attribution: {
      channel: "upload",
      credential_id: "credential_0000000000000000",
      connection_id: "conn_0000000000000000",
      actor: "string"
    },
    document_hash: "string",
    supplier: {
      document: {
        value: "string",
        from: "parser_local",
        evidence: {
          page: 0,
          excerpt: "string"
        },
        confidence: 0
      },
      name: {
        value: "string",
        from: "parser_local",
        evidence: {
          page: 0,
          excerpt: "string"
        },
        confidence: 0
      }
    },
    recipient: {
      document: {
        value: "string",
        from: "parser_local",
        evidence: {
          page: 0,
          excerpt: "string"
        },
        confidence: 0
      },
      name: {
        value: "string",
        from: "parser_local",
        evidence: {
          page: 0,
          excerpt: "string"
        },
        confidence: 0
      }
    },
    invoice_number: {
      value: "string",
      from: "parser_local",
      evidence: {
        page: 0,
        excerpt: "string"
      },
      confidence: 0
    },
    serie: {
      value: "string",
      from: "parser_local",
      evidence: {
        page: 0,
        excerpt: "string"
      },
      confidence: 0
    },
    issue_date: {
      value: "string",
      from: "parser_local",
      evidence: {
        page: 0,
        excerpt: "string"
      },
      confidence: 0
    },
    due_date: {
      value: "string",
      from: "parser_local",
      evidence: {
        page: 0,
        excerpt: "string"
      },
      confidence: 0
    },
    items: [
      {
        description: {
          value: "string",
          from: "parser_local",
          evidence: {
            page: 0,
            excerpt: "string"
          },
          confidence: 0
        },
        quantity: {
          value: 1000,
          from: "parser_local",
          evidence: {
            page: 0,
            excerpt: "string"
          },
          confidence: 0
        },
        unit_amount_minor: {
          value: 1000,
          from: "parser_local",
          evidence: {
            page: 0,
            excerpt: "string"
          },
          confidence: 0
        },
        total_amount_minor: {
          value: 1000,
          from: "parser_local",
          evidence: {
            page: 0,
            excerpt: "string"
          },
          confidence: 0
        }
      }
    ],
    totals: {
      subtotal_minor: {
        value: 1000,
        from: "parser_local",
        evidence: {
          page: 0,
          excerpt: "string"
        },
        confidence: 0
      },
      discount_minor: {
        value: 1000,
        from: "parser_local",
        evidence: {
          page: 0,
          excerpt: "string"
        },
        confidence: 0
      },
      tax_relief_deducted_minor: {
        value: 1000,
        from: "parser_local",
        evidence: {
          page: 0,
          excerpt: "string"
        },
        confidence: 0
      },
      freight_minor: {
        value: 1000,
        from: "parser_local",
        evidence: {
          page: 0,
          excerpt: "string"
        },
        confidence: 0
      },
      insurance_minor: {
        value: 1000,
        from: "parser_local",
        evidence: {
          page: 0,
          excerpt: "string"
        },
        confidence: 0
      },
      other_charges_minor: {
        value: 1000,
        from: "parser_local",
        evidence: {
          page: 0,
          excerpt: "string"
        },
        confidence: 0
      },
      taxes_added_minor: {
        value: 1000,
        from: "parser_local",
        evidence: {
          page: 0,
          excerpt: "string"
        },
        confidence: 0
      },
      taxes_included_minor: {
        value: 1000,
        from: "parser_local",
        evidence: {
          page: 0,
          excerpt: "string"
        },
        confidence: 0
      },
      grand_total_minor: {
        value: 1000,
        from: "parser_local",
        evidence: {
          page: 0,
          excerpt: "string"
        },
        confidence: 0
      },
      currency: {
        value: "string",
        from: "parser_local",
        evidence: {
          page: 0,
          excerpt: "string"
        },
        confidence: 0
      }
    },
    carriers: {
      boleto: "string",
      br_code: "string",
      nfe: "string"
    },
    extraction: {
      model: "string",
      model_version: "string",
      input_tokens: 0,
      output_tokens: 0,
      reasoning_tokens: 0
    }
  }
});
// r.status is one of the documented statuses (200, 422),
// each with its own body shape in r.data; nothing here throws on 422.
if (r.ok) {
  console.log(r.data);
}

This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.

Parameters, body and every documented response: POST /v1/payables in the HTTP reference.

GET /v1/payables/{payableId}

Read a payable

const result = await cs.api.get("/v1/payables/{payableId}", {
  path: {
    payableId: "payable_0000000000000000"
  }
});

This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.

Parameters, body and every documented response: GET /v1/payables/{payableId} in the HTTP reference.

Payables | CodeSpar