Developer-friendly & type-safe Typescript SDK specifically catered to leverage *apideck* API.
npm install @apideck/sdkDeveloper-friendly & type-safe Typescript SDK specifically catered to leverage apideck API.
> [!IMPORTANT]
> This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your workspace. Delete this section before > publishing to a package manager.
Apideck: The Apideck OpenAPI Spec: SDK Optimized
For more information about the API: Apideck Developer Docs
* SDK Installation
* Requirements
* SDK Example Usage
* Available Resources and Operations
* Standalone functions
* Retries
* Error Handling
* Server Selection
* Custom HTTP Client
* Authentication
* Debugging
The SDK can be installed with either npm, pnpm, bun or yarn package managers.
``bash`
npm add @apideck/sdk
`bash`
pnpm add @apideck/sdk
`bash`
bun add @apideck/sdk
`bash
yarn add @apideck/sdk zod
Requirements
For supported JavaScript runtimes, please consult RUNTIMES.md.
SDK Example Usage
$3
`typescript
import { Apideck } from "@apideck/sdk";const apideck = new Apideck({
apiKey: process.env["APIDECK_API_KEY"] ?? "",
consumerId: "test-consumer",
appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
});
async function run() {
const result = await apideck.accounting.taxRates.list({
serviceId: "salesforce",
filter: {
assets: true,
equity: true,
expenses: true,
liabilities: true,
revenue: true,
},
passThrough: {
"search": "San Francisco",
},
fields: "id,updated_at",
});
// Handle the result
console.log(result);
}
run();
`
Available Resources and Operations
Available methods
$3
* list - List Attachments
* get - Get Attachment
* delete - Delete Attachment
* download - Download Attachment
* get - Get BalanceSheet
* list - List Bill Payments
* create - Create Bill Payment
* get - Get Bill Payment
* update - Update Bill Payment
* delete - Delete Bill Payment
#### accounting.bills
* list - List Bills
* create - Create Bill
* get - Get Bill
* update - Update Bill
* delete - Delete Bill
* get - Get company info
* list - List Credit Notes
* create - Create Credit Note
* get - Get Credit Note
* update - Update Credit Note
* delete - Delete Credit Note
#### accounting.customers
* list - List Customers
* create - Create Customer
* get - Get Customer
* update - Update Customer
* delete - Delete Customer
* list - List Departments
* create - Create Department
* get - Get Department
* update - Update Department
* delete - Delete Department
#### accounting.expenses
* list - List Expenses
* create - Create Expense
* get - Get Expense
* update - Update Expense
* delete - Delete Expense
* list - List Invoice Items
* create - Create Invoice Item
* get - Get Invoice Item
* update - Update Invoice Item
* delete - Delete Invoice Item
#### accounting.invoices
* list - List Invoices
* create - Create Invoice
* get - Get Invoice
* update - Update Invoice
* delete - Delete Invoice
#### accounting.journalEntries
* list - List Journal Entries
* create - Create Journal Entry
* get - Get Journal Entry
* update - Update Journal Entry
* delete - Delete Journal Entry
#### accounting.ledgerAccounts
* list - List Ledger Accounts
* create - Create Ledger Account
* get - Get Ledger Account
* update - Update Ledger Account
* delete - Delete Ledger Account
#### accounting.locations
* list - List Locations
* create - Create Location
* get - Get Location
* update - Update Location
* delete - Delete Location
#### accounting.payments
* list - List Payments
* create - Create Payment
* get - Get Payment
* update - Update Payment
* delete - Delete Payment
* get - Get Profit and Loss
#### accounting.purchaseOrders
* list - List Purchase Orders
* create - Create Purchase Order
* get - Get Purchase Order
* update - Update Purchase Order
* delete - Delete Purchase Order
* list - List Subsidiaries
* create - Create Subsidiary
* get - Get Subsidiary
* update - Update Subsidiary
* delete - Delete Subsidiary
#### accounting.suppliers
* list - List Suppliers
* create - Create Supplier
* get - Get Supplier
* update - Update Supplier
* delete - Delete Supplier
#### accounting.taxRates
* list - List Tax Rates
* create - Create Tax Rate
* get - Get Tax Rate
* update - Update Tax Rate
* delete - Delete Tax Rate
#### accounting.trackingCategories
* list - List Tracking Categories
* create - Create Tracking Category
* get - Get Tracking Category
* update - Update Tracking Category
* delete - Delete Tracking Category
$3
#### ats.applicants
* list - List Applicants
* create - Create Applicant
* get - Get Applicant
* update - Update Applicant
* delete - Delete Applicant
#### ats.applications
* list - List Applications
* create - Create Application
* get - Get Application
* update - Update Application
* delete - Delete Application
#### ats.jobs
* list - List Jobs
* get - Get Job
$3
#### connector.apiResourceCoverage
* get - Get API Resource Coverage
* get - Get API Resource
#### connector.apis
* list - List APIs
* get - Get API
* get - Get Connector Doc content
#### connector.connectorResources
* get - Get Connector Resource
#### connector.connectors
* list - List Connectors
* get - Get Connector
$3
#### crm.activities
* list - List activities
* create - Create activity
* get - Get activity
* update - Update activity
* delete - Delete activity
#### crm.companies
* list - List companies
* create - Create company
* get - Get company
* update - Update company
* delete - Delete company
#### crm.contacts
* list - List contacts
* create - Create contact
* get - Get contact
* update - Update contact
* delete - Delete contact
#### crm.leads
* list - List leads
* create - Create lead
* get - Get lead
* update - Update lead
* delete - Delete lead
#### crm.notes
* list - List notes
* create - Create note
* get - Get note
* update - Update note
* delete - Delete note
#### crm.opportunities
* list - List opportunities
* create - Create opportunity
* get - Get opportunity
* update - Update opportunity
* delete - Delete opportunity
#### crm.pipelines
* list - List pipelines
* create - Create pipeline
* get - Get pipeline
* update - Update pipeline
* delete - Delete pipeline
#### crm.users
* list - List users
* create - Create user
* get - Get user
* update - Update user
* delete - Delete user
$3
#### ecommerce.customers
* list - List Customers
* get - Get Customer
#### ecommerce.orders
* list - List Orders
* get - Get Order
#### ecommerce.products
* list - List Products
* get - Get Product
#### ecommerce.stores
* get - Get Store
$3
* list - List DriveGroups
* create - Create DriveGroup
* get - Get DriveGroup
* update - Update DriveGroup
* delete - Delete DriveGroup
#### fileStorage.drives
* list - List Drives
* create - Create Drive
* get - Get Drive
* update - Update Drive
* delete - Delete Drive
#### fileStorage.files
* list - List Files
* search - Search Files
* get - Get File
* update - Rename or move File
* delete - Delete File
* download - Download File
* export - Export File
#### fileStorage.folders
* create - Create Folder
* get - Get Folder
* update - Rename or move Folder
* delete - Delete Folder
* copy - Copy Folder
* list - List SharedLinks
* create - Create Shared Link
* get - Get Shared Link
* update - Update Shared Link
* delete - Delete Shared Link
#### fileStorage.uploadSessions
* create - Start Upload Session
* get - Get Upload Session
* delete - Abort Upload Session
* finish - Finish Upload Session
$3
#### hris.companies
* list - List Companies
* create - Create Company
* get - Get Company
* update - Update Company
* delete - Delete Company
#### hris.departments
* list - List Departments
* create - Create Department
* get - Get Department
* update - Update Department
* delete - Delete Department
* list - List Employee Payrolls
* get - Get Employee Payroll
#### hris.employees
* list - List Employees
* create - Create Employee
* get - Get Employee
* update - Update Employee
* delete - Delete Employee
* list - List Employee Schedules
#### hris.payrolls
* list - List Payroll
* get - Get Payroll
#### hris.timeOffRequests
* list - List Time Off Requests
* create - Create Time Off Request
* get - Get Time Off Request
* update - Update Time Off Request
* delete - Delete Time Off Request
$3
#### issueTracking.collections
* list - List Collections
* get - Get Collection
#### issueTracking.collectionTags
* list - List Tags
#### issueTracking.collectionTicketComments
* list - List Comments
* create - Create Comment
* get - Get Comment
* update - Update Comment
* delete - Delete Comment
#### issueTracking.collectionTickets
* list - List Tickets
* create - Create Ticket
* get - Get Ticket
* update - Update Ticket
* delete - Delete Ticket
#### issueTracking.collectionUsers
* list - List Users
* get - Get user
$3
#### sms.messages
* list - List Messages
* create - Create Message
* get - Get Message
* update - Update Message
* delete - Delete Message
$3
#### vault.connectionCustomMappings
* list - List connection custom mappings
#### vault.connections
* list - Get all connections
* get - Get connection
* update - Update connection
* delete - Deletes a connection
* imports - Import connection
* token - Authorize Access Token
* list - Get resource settings
* update - Update settings
#### vault.consumerRequestCounts
* list - Consumer request counts
#### vault.consumers
* create - Create consumer
* list - Get all consumers
* get - Get consumer
* update - Update consumer
* delete - Delete consumer
#### vault.createCallback
* state - Create Callback State
#### vault.customFields
* list - Get resource custom fields
#### vault.customMappings
* list - List custom mappings
#### vault.logs
* list - Get all consumer request logs
#### vault.sessions
* create - Create Session
* state - Validate Connection State
$3
#### webhook.eventLogs
* list - List event logs
#### webhook.webhooks
* list - List webhook subscriptions
* create - Create webhook subscription
* get - Get webhook subscription
* update - Update webhook subscription
* delete - Delete webhook subscription
Standalone functions
All the methods listed above are available as standalone functions. These
functions are ideal for use in applications running in the browser, serverless
runtimes or other environments where application bundle size is a primary
concern. When using a bundler to build your application, all unused
functionality will be either excluded from the final bundle or tree-shaken away.
To read more about standalone functions, check FUNCTIONS.md.
Available standalone functions
accountingAttachmentsDelete - Delete Attachment
- accountingAttachmentsDownload - Download Attachment
- accountingAttachmentsGet - Get Attachment
- accountingAttachmentsList - List Attachments
- accountingBalanceSheetGet - Get BalanceSheet
- accountingBillPaymentsCreate - Create Bill Payment
- accountingBillPaymentsDelete - Delete Bill Payment
- accountingBillPaymentsGet - Get Bill Payment
- accountingBillPaymentsList - List Bill Payments
- accountingBillPaymentsUpdate - Update Bill Payment
- accountingBillsCreate - Create Bill
- accountingBillsDelete - Delete Bill
- accountingBillsGet - Get Bill
- accountingBillsList - List Bills
- accountingBillsUpdate - Update Bill
- accountingCompanyInfoGet - Get company info
- accountingCreditNotesCreate - Create Credit Note
- accountingCreditNotesDelete - Delete Credit Note
- accountingCreditNotesGet - Get Credit Note
- accountingCreditNotesList - List Credit Notes
- accountingCreditNotesUpdate - Update Credit Note
- accountingCustomersCreate - Create Customer
- accountingCustomersDelete - Delete Customer
- accountingCustomersGet - Get Customer
- accountingCustomersList - List Customers
- accountingCustomersUpdate - Update Customer
- accountingDepartmentsCreate - Create Department
- accountingDepartmentsDelete - Delete Department
- accountingDepartmentsGet - Get Department
- accountingDepartmentsList - List Departments
- accountingDepartmentsUpdate - Update Department
- accountingExpensesCreate - Create Expense
- accountingExpensesDelete - Delete Expense
- accountingExpensesGet - Get Expense
- accountingExpensesList - List Expenses
- accountingExpensesUpdate - Update Expense
- accountingInvoiceItemsCreate - Create Invoice Item
- accountingInvoiceItemsDelete - Delete Invoice Item
- accountingInvoiceItemsGet - Get Invoice Item
- accountingInvoiceItemsList - List Invoice Items
- accountingInvoiceItemsUpdate - Update Invoice Item
- accountingInvoicesCreate - Create Invoice
- accountingInvoicesDelete - Delete Invoice
- accountingInvoicesGet - Get Invoice
- accountingInvoicesList - List Invoices
- accountingInvoicesUpdate - Update Invoice
- accountingJournalEntriesCreate - Create Journal Entry
- accountingJournalEntriesDelete - Delete Journal Entry
- accountingJournalEntriesGet - Get Journal Entry
- accountingJournalEntriesList - List Journal Entries
- accountingJournalEntriesUpdate - Update Journal Entry
- accountingLedgerAccountsCreate - Create Ledger Account
- accountingLedgerAccountsDelete - Delete Ledger Account
- accountingLedgerAccountsGet - Get Ledger Account
- accountingLedgerAccountsList - List Ledger Accounts
- accountingLedgerAccountsUpdate - Update Ledger Account
- accountingLocationsCreate - Create Location
- accountingLocationsDelete - Delete Location
- accountingLocationsGet - Get Location
- accountingLocationsList - List Locations
- accountingLocationsUpdate - Update Location
- accountingPaymentsCreate - Create Payment
- accountingPaymentsDelete - Delete Payment
- accountingPaymentsGet - Get Payment
- accountingPaymentsList - List Payments
- accountingPaymentsUpdate - Update Payment
- accountingProfitAndLossGet - Get Profit and Loss
- accountingPurchaseOrdersCreate - Create Purchase Order
- accountingPurchaseOrdersDelete - Delete Purchase Order
- accountingPurchaseOrdersGet - Get Purchase Order
- accountingPurchaseOrdersList - List Purchase Orders
- accountingPurchaseOrdersUpdate - Update Purchase Order
- accountingSubsidiariesCreate - Create Subsidiary
- accountingSubsidiariesDelete - Delete Subsidiary
- accountingSubsidiariesGet - Get Subsidiary
- accountingSubsidiariesList - List Subsidiaries
- accountingSubsidiariesUpdate - Update Subsidiary
- accountingSuppliersCreate - Create Supplier
- accountingSuppliersDelete - Delete Supplier
- accountingSuppliersGet - Get Supplier
- accountingSuppliersList - List Suppliers
- accountingSuppliersUpdate - Update Supplier
- accountingTaxRatesCreate - Create Tax Rate
- accountingTaxRatesDelete - Delete Tax Rate
- accountingTaxRatesGet - Get Tax Rate
- accountingTaxRatesList - List Tax Rates
- accountingTaxRatesUpdate - Update Tax Rate
- accountingTrackingCategoriesCreate - Create Tracking Category
- accountingTrackingCategoriesDelete - Delete Tracking Category
- accountingTrackingCategoriesGet - Get Tracking Category
- accountingTrackingCategoriesList - List Tracking Categories
- accountingTrackingCategoriesUpdate - Update Tracking Category
- atsApplicantsCreate - Create Applicant
- atsApplicantsDelete - Delete Applicant
- atsApplicantsGet - Get Applicant
- atsApplicantsList - List Applicants
- atsApplicantsUpdate - Update Applicant
- atsApplicationsCreate - Create Application
- atsApplicationsDelete - Delete Application
- atsApplicationsGet - Get Application
- atsApplicationsList - List Applications
- atsApplicationsUpdate - Update Application
- atsJobsGet - Get Job
- atsJobsList - List Jobs
- connectorApiResourceCoverageGet - Get API Resource Coverage
- connectorApiResourcesGet - Get API Resource
- connectorApisGet - Get API
- connectorApisList - List APIs
- connectorConnectorDocsGet - Get Connector Doc content
- connectorConnectorResourcesGet - Get Connector Resource
- connectorConnectorsGet - Get Connector
- connectorConnectorsList - List Connectors
- crmActivitiesCreate - Create activity
- crmActivitiesDelete - Delete activity
- crmActivitiesGet - Get activity
- crmActivitiesList - List activities
- crmActivitiesUpdate - Update activity
- crmCompaniesCreate - Create company
- crmCompaniesDelete - Delete company
- crmCompaniesGet - Get company
- crmCompaniesList - List companies
- crmCompaniesUpdate - Update company
- crmContactsCreate - Create contact
- crmContactsDelete - Delete contact
- crmContactsGet - Get contact
- crmContactsList - List contacts
- crmContactsUpdate - Update contact
- crmLeadsCreate - Create lead
- crmLeadsDelete - Delete lead
- crmLeadsGet - Get lead
- crmLeadsList - List leads
- crmLeadsUpdate - Update lead
- crmNotesCreate - Create note
- crmNotesDelete - Delete note
- crmNotesGet - Get note
- crmNotesList - List notes
- crmNotesUpdate - Update note
- crmOpportunitiesCreate - Create opportunity
- crmOpportunitiesDelete - Delete opportunity
- crmOpportunitiesGet - Get opportunity
- crmOpportunitiesList - List opportunities
- crmOpportunitiesUpdate - Update opportunity
- crmPipelinesCreate - Create pipeline
- crmPipelinesDelete - Delete pipeline
- crmPipelinesGet - Get pipeline
- crmPipelinesList - List pipelines
- crmPipelinesUpdate - Update pipeline
- crmUsersCreate - Create user
- crmUsersDelete - Delete user
- crmUsersGet - Get user
- crmUsersList - List users
- crmUsersUpdate - Update user
- ecommerceCustomersGet - Get Customer
- ecommerceCustomersList - List Customers
- ecommerceOrdersGet - Get Order
- ecommerceOrdersList - List Orders
- ecommerceProductsGet - Get Product
- ecommerceProductsList - List Products
- ecommerceStoresGet - Get Store
- fileStorageDriveGroupsCreate - Create DriveGroup
- fileStorageDriveGroupsDelete - Delete DriveGroup
- fileStorageDriveGroupsGet - Get DriveGroup
- fileStorageDriveGroupsList - List DriveGroups
- fileStorageDriveGroupsUpdate - Update DriveGroup
- fileStorageDrivesCreate - Create Drive
- fileStorageDrivesDelete - Delete Drive
- fileStorageDrivesGet - Get Drive
- fileStorageDrivesList - List Drives
- fileStorageDrivesUpdate - Update Drive
- fileStorageFilesDelete - Delete File
- fileStorageFilesDownload - Download File
- fileStorageFilesExport - Export File
- fileStorageFilesGet - Get File
- fileStorageFilesList - List Files
- fileStorageFilesSearch - Search Files
- fileStorageFilesUpdate - Rename or move File
- fileStorageFoldersCopy - Copy Folder
- fileStorageFoldersCreate - Create Folder
- fileStorageFoldersDelete - Delete Folder
- fileStorageFoldersGet - Get Folder
- fileStorageFoldersUpdate - Rename or move Folder
- fileStorageSharedLinksCreate - Create Shared Link
- fileStorageSharedLinksDelete - Delete Shared Link
- fileStorageSharedLinksGet - Get Shared Link
- fileStorageSharedLinksList - List SharedLinks
- fileStorageSharedLinksUpdate - Update Shared Link
- fileStorageUploadSessionsCreate - Start Upload Session
- fileStorageUploadSessionsDelete - Abort Upload Session
- fileStorageUploadSessionsFinish - Finish Upload Session
- fileStorageUploadSessionsGet - Get Upload Session
- hrisCompaniesCreate - Create Company
- hrisCompaniesDelete - Delete Company
- hrisCompaniesGet - Get Company
- hrisCompaniesList - List Companies
- hrisCompaniesUpdate - Update Company
- hrisDepartmentsCreate - Create Department
- hrisDepartmentsDelete - Delete Department
- hrisDepartmentsGet - Get Department
- hrisDepartmentsList - List Departments
- hrisDepartmentsUpdate - Update Department
- hrisEmployeePayrollsGet - Get Employee Payroll
- hrisEmployeePayrollsList - List Employee Payrolls
- hrisEmployeeSchedulesList - List Employee Schedules
- hrisEmployeesCreate - Create Employee
- hrisEmployeesDelete - Delete Employee
- hrisEmployeesGet - Get Employee
- hrisEmployeesList - List Employees
- hrisEmployeesUpdate - Update Employee
- hrisPayrollsGet - Get Payroll
- hrisPayrollsList - List Payroll
- hrisTimeOffRequestsCreate - Create Time Off Request
- hrisTimeOffRequestsDelete - Delete Time Off Request
- hrisTimeOffRequestsGet - Get Time Off Request
- hrisTimeOffRequestsList - List Time Off Requests
- hrisTimeOffRequestsUpdate - Update Time Off Request
- issueTrackingCollectionsGet - Get Collection
- issueTrackingCollectionsList - List Collections
- issueTrackingCollectionTagsList - List Tags
- issueTrackingCollectionTicketCommentsCreate - Create Comment
- issueTrackingCollectionTicketCommentsDelete - Delete Comment
- issueTrackingCollectionTicketCommentsGet - Get Comment
- issueTrackingCollectionTicketCommentsList - List Comments
- issueTrackingCollectionTicketCommentsUpdate - Update Comment
- issueTrackingCollectionTicketsCreate - Create Ticket
- issueTrackingCollectionTicketsDelete - Delete Ticket
- issueTrackingCollectionTicketsGet - Get Ticket
- issueTrackingCollectionTicketsList - List Tickets
- issueTrackingCollectionTicketsUpdate - Update Ticket
- issueTrackingCollectionUsersGet - Get user
- issueTrackingCollectionUsersList - List Users
- smsMessagesCreate - Create Message
- smsMessagesDelete - Delete Message
- smsMessagesGet - Get Message
- smsMessagesList - List Messages
- smsMessagesUpdate - Update Message
- vaultConnectionCustomMappingsList - List connection custom mappings
- vaultConnectionsDelete - Deletes a connection
- vaultConnectionSettingsList - Get resource settings
- vaultConnectionSettingsUpdate - Update settings
- vaultConnectionsGet - Get connection
- vaultConnectionsImports - Import connection
- vaultConnectionsList - Get all connections
- vaultConnectionsToken - Authorize Access Token
- vaultConnectionsUpdate - Update connection
- vaultConsumerRequestCountsList - Consumer request counts
- vaultConsumersCreate - Create consumer
- vaultConsumersDelete - Delete consumer
- vaultConsumersGet - Get consumer
- vaultConsumersList - Get all consumers
- vaultConsumersUpdate - Update consumer
- vaultCreateCallbackState - Create Callback State
- vaultCustomFieldsList - Get resource custom fields
- vaultCustomMappingsList - List custom mappings
- vaultLogsList - Get all consumer request logs
- vaultSessionsCreate - Create Session
- vaultValidateConnectionState - Validate Connection State
- webhookEventLogsList - List event logs
- webhookWebhooksCreate - Create webhook subscription
- webhookWebhooksDelete - Delete webhook subscription
- webhookWebhooksGet - Get webhook subscription
- webhookWebhooksList - List webhook subscriptions
- webhookWebhooksUpdate - Update webhook subscription
Retries
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
`typescript
import { Apideck } from "@apideck/sdk";const apideck = new Apideck({
apiKey: process.env["APIDECK_API_KEY"] ?? "",
consumerId: "test-consumer",
appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
});
async function run() {
const result = await apideck.accounting.taxRates.list({
serviceId: "salesforce",
filter: {
assets: true,
equity: true,
expenses: true,
liabilities: true,
revenue: true,
},
passThrough: {
"search": "San Francisco",
},
fields: "id,updated_at",
}, {
retries: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
});
// Handle the result
console.log(result);
}
run();
`If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
`typescript
import { Apideck } from "@apideck/sdk";const apideck = new Apideck({
retryConfig: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
apiKey: process.env["APIDECK_API_KEY"] ?? "",
consumerId: "test-consumer",
appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
});
async function run() {
const result = await apideck.accounting.taxRates.list({
serviceId: "salesforce",
filter: {
assets: true,
equity: true,
expenses: true,
liabilities: true,
revenue: true,
},
passThrough: {
"search": "San Francisco",
},
fields: "id,updated_at",
});
// Handle the result
console.log(result);
}
run();
`
Error Handling
All SDK methods return a response object or throw an error. By default, an API error will throw a
errors.APIError.If a HTTP request fails, an operation my also throw an error from the
models/errors/httpclienterrors.ts module:| HTTP Client Error | Description |
| ---------------------------------------------------- | ---------------------------------------------------- |
| RequestAbortedError | HTTP request was aborted by the client |
| RequestTimeoutError | HTTP request timed out due to an AbortSignal signal |
| ConnectionError | HTTP client was unable to make a request to a server |
| InvalidRequestError | Any input used to create a request is invalid |
| UnexpectedClientError | Unrecognised or unexpected error |
In addition, when custom error responses are specified for an operation, the SDK may throw their associated Error type. You can refer to respective Errors tables in SDK docs for more details on possible error types for each operation. For example, the
list method may throw the following errors:| Error Type | Status Code | Content Type |
| ------------------------------ | ----------- | ---------------- |
| errors.BadRequestResponse | 400 | application/json |
| errors.UnauthorizedResponse | 401 | application/json |
| errors.PaymentRequiredResponse | 402 | application/json |
| errors.NotFoundResponse | 404 | application/json |
| errors.UnprocessableResponse | 422 | application/json |
| errors.APIError | 4XX, 5XX | \/\ |
`typescript
import { Apideck } from "@apideck/sdk";
import {
BadRequestResponse,
NotFoundResponse,
PaymentRequiredResponse,
SDKValidationError,
UnauthorizedResponse,
UnprocessableResponse,
} from "@apideck/sdk/models/errors";const apideck = new Apideck({
apiKey: process.env["APIDECK_API_KEY"] ?? "",
consumerId: "test-consumer",
appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
});
async function run() {
let result;
try {
result = await apideck.accounting.taxRates.list({
serviceId: "salesforce",
filter: {
assets: true,
equity: true,
expenses: true,
liabilities: true,
revenue: true,
},
passThrough: {
"search": "San Francisco",
},
fields: "id,updated_at",
});
// Handle the result
console.log(result);
} catch (err) {
switch (true) {
case (err instanceof SDKValidationError): {
// Validation errors can be pretty-printed
console.error(err.pretty());
// Raw value may also be inspected
console.error(err.rawValue);
return;
}
case (err instanceof BadRequestResponse): {
// Handle err.data$: BadRequestResponseData
console.error(err);
return;
}
case (err instanceof UnauthorizedResponse): {
// Handle err.data$: UnauthorizedResponseData
console.error(err);
return;
}
case (err instanceof PaymentRequiredResponse): {
// Handle err.data$: PaymentRequiredResponseData
console.error(err);
return;
}
case (err instanceof NotFoundResponse): {
// Handle err.data$: NotFoundResponseData
console.error(err);
return;
}
case (err instanceof UnprocessableResponse): {
// Handle err.data$: UnprocessableResponseData
console.error(err);
return;
}
default: {
throw err;
}
}
}
}
run();
`Validation errors can also occur when either method arguments or data returned from the server do not match the expected format. The
SDKValidationError that is thrown as a result will capture the raw value that failed validation in an attribute called rawValue. Additionally, a pretty() method is available on this error that can be used to log a nicely formatted string since validation errors can list many issues and the plain error string may be difficult read when debugging.
Server Selection
$3
The default server can also be overridden globally by passing a URL to the
serverURL: string optional parameter when initializing the SDK client instance. For example:
`typescript
import { Apideck } from "@apideck/sdk";const apideck = new Apideck({
serverURL: "https://unify.apideck.com",
apiKey: process.env["APIDECK_API_KEY"] ?? "",
consumerId: "test-consumer",
appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
});
async function run() {
const result = await apideck.accounting.taxRates.list({
serviceId: "salesforce",
filter: {
assets: true,
equity: true,
expenses: true,
liabilities: true,
revenue: true,
},
passThrough: {
"search": "San Francisco",
},
fields: "id,updated_at",
});
// Handle the result
console.log(result);
}
run();
`$3
The server URL can also be overridden on a per-operation basis, provided a server list was specified for the operation. For example:
`typescript
import { Apideck } from "@apideck/sdk";const apideck = new Apideck({
apiKey: process.env["APIDECK_API_KEY"] ?? "",
consumerId: "test-consumer",
appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
});
async function run() {
const result = await apideck.fileStorage.uploadSessions.create({
serviceId: "salesforce",
createUploadSessionRequest: {
name: "Documents",
parentFolderId: "1234",
driveId: "1234",
size: 1810673,
passThrough: [
{
serviceId: "",
extendPaths: [
{
path: "$.nested.property",
value: {
"TaxClassificationRef": {
"value": "EUC-99990201-V1-00020000",
},
},
},
],
},
],
},
}, {
serverURL: "https://upload.apideck.com",
});
// Handle the result
console.log(result);
}
run();
`
Custom HTTP Client
The TypeScript SDK makes API calls using an
HTTPClient that wraps the native
Fetch API. This
client is a thin wrapper around fetch and provides the ability to attach hooks
around the request lifecycle that can be used to modify the request or handle
errors and response.The
HTTPClient constructor takes an optional fetcher argument that can be
used to integrate a third-party HTTP client or when writing tests to mock out
the HTTP client and feed in fixtures.The following example shows how to use the
"beforeRequest" hook to to add a
custom header and a timeout to requests and how to use the "requestError" hook
to log errors:`typescript
import { Apideck } from "@apideck/sdk";
import { HTTPClient } from "@apideck/sdk/lib/http";const httpClient = new HTTPClient({
// fetcher takes a function that has the same signature as native
fetch.
fetcher: (request) => {
return fetch(request);
}
});httpClient.addHook("beforeRequest", (request) => {
const nextRequest = new Request(request, {
signal: request.signal || AbortSignal.timeout(5000)
});
nextRequest.headers.set("x-custom-header", "custom value");
return nextRequest;
});
httpClient.addHook("requestError", (error, request) => {
console.group("Request Error");
console.log("Reason:",
${error});
console.log("Endpoint:", ${request.method} ${request.url});
console.groupEnd();
});const sdk = new Apideck({ httpClient });
`
Authentication
$3
This SDK supports the following security scheme globally:
| Name | Type | Scheme | Environment Variable |
| -------- | ------ | ------- | -------------------- |
|
apiKey | apiKey | API key | APIDECK_API_KEY |To authenticate with the API the
apiKey parameter must be set when initializing the SDK client instance. For example:
`typescript
import { Apideck } from "@apideck/sdk";const apideck = new Apideck({
apiKey: process.env["APIDECK_API_KEY"] ?? "",
consumerId: "test-consumer",
appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
});
async function run() {
const result = await apideck.accounting.taxRates.list({
serviceId: "salesforce",
filter: {
assets: true,
equity: true,
expenses: true,
liabilities: true,
revenue: true,
},
passThrough: {
"search": "San Francisco",
},
fields: "id,updated_at",
});
// Handle the result
console.log(result);
}
run();
`
Debugging
You can setup your SDK to emit debug logs for SDK requests and responses.
You can pass a logger that matches
console's interface as an SDK option.> [!WARNING]
> Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.
`typescript
import { Apideck } from "@apideck/sdk";const sdk = new Apideck({ debugLogger: console });
`You can also enable a default debug logger by setting an environment variable
APIDECK_DEBUG` to true.This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally
looking for the latest version.
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation.
We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.