{"files":{"SKILL.md":"---\nname: sync-for-expenses-api\ndescription: \"Sync for Expenses API skill. Use when working with Sync for Expenses for companies. Covers 13 endpoints.\"\nversion: 1.0.0\ngenerator: lapsh\n---\n\n# Sync for Expenses API\nAPI version: prealpha\n\n## Auth\nApiKey Authorization in header\n\n## Base URL\nhttps://api.codat.io\n\n## Setup\n1. Set your API key in the appropriate header\n2. GET /companies/{companyId}/sync/expenses/config -- get company configuration\n3. POST /companies/{companyId}/sync/expenses/config -- create first config\n\n## Endpoints\n13 endpoints across 1 group. See references/api-spec.lap for full details.\n\n### Companies\n| Method | Path | Description |\n|--------|------|-------------|\n| GET | /companies/{companyId}/sync/expenses/config | Get company configuration |\n| POST | /companies/{companyId}/sync/expenses/config | Set company configuration |\n| GET | /companies/{companyId}/sync/expenses/mappingOptions | Mapping options |\n| POST | /companies/{companyId}/sync/expenses/syncs | Initiate sync |\n| GET | /companies/{companyId}/sync/expenses/syncs/lastSuccessful/status | Last successful sync |\n| GET | /companies/{companyId}/sync/expenses/syncs/latest/status | Latest sync status |\n| GET | /companies/{companyId}/sync/expenses/syncs/list/status | List sync statuses |\n| GET | /companies/{companyId}/sync/expenses/syncs/{syncId}/status | Get Sync status |\n| GET | /companies/{companyId}/sync/expenses/syncs/{syncId}/transactions | Get Sync transactions |\n| GET | /companies/{companyId}/sync/expenses/syncs/{syncId}/transactions/{transactionId} | Get Sync Transaction |\n| POST | /companies/{companyId}/sync/expenses/data/expense-transactions | Create expense-transactions |\n| PUT | /companies/{companyId}/sync/expenses/expense-transactions/{transactionId} | Update expense-transactions |\n| POST | /companies/{companyId}/sync/expenses/syncs/{syncId}/transactions/{transactionId}/attachments | Upload attachment |\n\n## Common Questions\nMatch user requests to endpoints in references/api-spec.lap. Key patterns:\n- \"List all config?\" -> GET /companies/{companyId}/sync/expenses/config\n- \"Create a config?\" -> POST /companies/{companyId}/sync/expenses/config\n- \"List all mappingOptions?\" -> GET /companies/{companyId}/sync/expenses/mappingOptions\n- \"Create a sync?\" -> POST /companies/{companyId}/sync/expenses/syncs\n- \"List all status?\" -> GET /companies/{companyId}/sync/expenses/syncs/lastSuccessful/status\n- \"List all transactions?\" -> GET /companies/{companyId}/sync/expenses/syncs/{syncId}/transactions\n- \"Get transaction details?\" -> GET /companies/{companyId}/sync/expenses/syncs/{syncId}/transactions/{transactionId}\n- \"Create a expense-transaction?\" -> POST /companies/{companyId}/sync/expenses/data/expense-transactions\n- \"Update a expense-transaction?\" -> PUT /companies/{companyId}/sync/expenses/expense-transactions/{transactionId}\n- \"Create a attachment?\" -> POST /companies/{companyId}/sync/expenses/syncs/{syncId}/transactions/{transactionId}/attachments\n- \"How to authenticate?\" -> See Auth section above\n\n## Response Tips\n- Check response schemas in references/api-spec.lap for field details\n- Paginated endpoints accept limit/offset or cursor parameters\n- Create/update endpoints return the modified resource on success\n- Error responses include status codes and descriptions in the spec\n\n## References\n- Full spec: See references/api-spec.lap for complete endpoint details, parameter tables, and response schemas\n\n> Generated from the official API spec by [LAP](https://lap.sh)\n","references/api-spec.lap":"@lap v0.3\n# Machine-readable API spec. Each @endpoint block is one API call.\n@api Sync for Expenses API\n@base https://api.codat.io\n@version prealpha\n@auth ApiKey Authorization in header\n@endpoints 13\n@toc companies(13)\n\n@endpoint GET /companies/{companyId}/sync/expenses/config\n@desc Get company configuration\n@returns(200) {bankAccount: map{id: str}, supplier: map{id: str}, customer: map{id: str}} # Success\n@errors {401: Your API request was not properly authorized., 404: One or more of the resources you referenced could not be found. This might be because your company or data connection id is wrong, or was already deleted., 429: Too many requests were made in a given amount of time. Wait a short period and then try again.}\n\n@endpoint POST /companies/{companyId}/sync/expenses/config\n@desc Set company configuration\n@required {bankAccount: map{id: str}, supplier: map{id: str}, customer: map{id: str}}\n@returns(200) {bankAccount: map{id: str}, supplier: map{id: str}, customer: map{id: str}} # Success\n@errors {400: The request made is not valid., 401: Your API request was not properly authorized., 404: One or more of the resources you referenced could not be found. This might be because your company or data connection id is wrong, or was already deleted., 429: Too many requests were made in a given amount of time. Wait a short period and then try again.}\n\n@endpoint GET /companies/{companyId}/sync/expenses/mappingOptions\n@desc Mapping options\n@returns(200) {expenseProvider: str?, accounts: [map]?, trackingCategories: [map]?, taxRates: [map]?} # Success\n@errors {401: Your API request was not properly authorized., 404: One or more of the resources you referenced could not be found. This might be because your company or data connection id is wrong, or was already deleted., 429: Too many requests were made in a given amount of time. Wait a short period and then try again.}\n\n@endpoint POST /companies/{companyId}/sync/expenses/syncs\n@desc Initiate sync\n@optional {datasetIds: [str(uuid)]}\n@returns(202) {syncId: str(uuid)} # Returns the newly created SyncId\n@errors {400: If model is incorrect, 404: If company not found, 422: If the specified company does not have a valid set of DataConnections setup}\n\n@endpoint GET /companies/{companyId}/sync/expenses/syncs/lastSuccessful/status\n@desc Last successful sync\n@returns(200) {companyId: str?, syncId: str?, syncStatusCode: int(int32), syncStatus: str?, errorMessage: str?, syncExceptionMessage: str?, syncUtc: str, dataPushed: bool} # Success\n@errors {401: Your API request was not properly authorized., 404: One or more of the resources you referenced could not be found. This might be because your company or data connection id is wrong, or was already deleted., 429: Too many requests were made in a given amount of time. Wait a short period and then try again.}\n\n@endpoint GET /companies/{companyId}/sync/expenses/syncs/latest/status\n@desc Latest sync status\n@returns(200) {companyId: str?, syncId: str?, syncStatusCode: int(int32), syncStatus: str?, errorMessage: str?, syncExceptionMessage: str?, syncUtc: str, dataPushed: bool} # Success\n@errors {401: Your API request was not properly authorized., 404: One or more of the resources you referenced could not be found. This might be because your company or data connection id is wrong, or was already deleted., 429: Too many requests were made in a given amount of time. Wait a short period and then try again.}\n\n@endpoint GET /companies/{companyId}/sync/expenses/syncs/list/status\n@desc List sync statuses\n@returns(200) Success\n@errors {401: Your API request was not properly authorized., 404: One or more of the resources you referenced could not be found. This might be because your company or data connection id is wrong, or was already deleted., 429: Too many requests were made in a given amount of time. Wait a short period and then try again.}\n\n@endpoint GET /companies/{companyId}/sync/expenses/syncs/{syncId}/status\n@desc Get Sync status\n@required {syncId: str(uuid) # Unique identifier for a sync.}\n@returns(200) {companyId: str?, syncId: str?, syncStatusCode: int(int32), syncStatus: str?, errorMessage: str?, syncExceptionMessage: str?, syncUtc: str, dataPushed: bool} # Success\n@errors {401: Your API request was not properly authorized., 404: One or more of the resources you referenced could not be found. This might be because your company or data connection id is wrong, or was already deleted., 429: Too many requests were made in a given amount of time. Wait a short period and then try again.}\n\n@endpoint GET /companies/{companyId}/sync/expenses/syncs/{syncId}/transactions\n@desc Get Sync transactions\n@required {syncId: str(uuid) # Unique identifier for a sync.}\n@optional {page: int(int32)=1 # Page number. [Read more](https://docs.codat.io/using-the-api/paging)., pageSize: int(int32)=100 # Number of records to return in a page. [Read more](https://docs.codat.io/using-the-api/paging).}\n@returns(200) Success\n@errors {401: Your API request was not properly authorized., 404: One or more of the resources you referenced could not be found. This might be because your company or data connection id is wrong, or was already deleted., 429: Too many requests were made in a given amount of time. Wait a short period and then try again.}\n\n@endpoint GET /companies/{companyId}/sync/expenses/syncs/{syncId}/transactions/{transactionId}\n@desc Get Sync Transaction\n@required {syncId: str(uuid) # Unique identifier for a sync., transactionId: str(uuid) # The unique identifier for your SMB's transaction.}\n@returns(200) Success\n@errors {401: Your API request was not properly authorized., 404: One or more of the resources you referenced could not be found. This might be because your company or data connection id is wrong, or was already deleted., 429: Too many requests were made in a given amount of time. Wait a short period and then try again.}\n\n@endpoint POST /companies/{companyId}/sync/expenses/data/expense-transactions\n@desc Create expense-transactions\n@optional {items: [map{id!: str(uuid), type!: str, issueDate!: str, currency!: str, currencyRate: num, contactRef: map, merchantName: str, lines: [map], notes: str}]}\n@returns(200) {datasetId: str(uuid)} # OK\n@errors {400: The request made is not valid., 401: Your API request was not properly authorized., 404: One or more of the resources you referenced could not be found. This might be because your company or data connection id is wrong, or was already deleted., 429: Too many requests were made in a given amount of time. Wait a short period and then try again.}\n@example_request {\"items\":[{\"id\":\"4d7c6929-7770-412b-91bb-44d3bc71d111\",\"type\":\"Payment\",\"issueDate\":\"2021-05-21T00:00:00+00:00\",\"currency\":\"GBP\",\"currencyRate\":1.18,\"contactRef\":{\"id\":\"f5244103-5223-4b0a-857f-50566ac86c11\",\"type\":\"Supplier\"},\"merchantName\":\"Amazon UK\",\"lines\":[{\"netAmount\":110.42,\"taxAmount\":14.43,\"taxRateRef\":{\"id\":\"77a32ee2-60c7-4ab9-917a-bd82e2e43a26\"},\"accountRef\":{\"id\":\"9aa5b894-1be9-4f97-96cd-ffde90766b3e\"},\"trackingRefs\":[{\"id\":\"dde5b35f-5d33-40bd-a34f-ee529f4c785c\"}]}],\"notes\":\"APPLE.COM/BILL - 09001077498 - Card Ending: 4590\"}]}\n\n@endpoint PUT /companies/{companyId}/sync/expenses/expense-transactions/{transactionId}\n@desc Update expense-transactions\n@required {type: str(Payment/Refund/Reward/Chargeback/TransferIn/TransferOut/AdjustmentIn/AdjustmentOut) # The type of transaction., issueDate: str # Date the transaction was recorded.}\n@optional {currency: str # Currency the transaction was recorded in., currencyRate: num # Rate to convert the total amount of the payment into the base currency for the company at the time of the payment.  Currency rates in Codat are implemented as the multiple of foreign currency units to each base currency unit.    It is not possible to perform the currency conversion with two or more non-base currencies participating in the transaction. For example, if a company's base currency is USD, and it has a bill issued in EUR, then the bill payment must happen in USD or EUR.  Where the currency rate is provided by the underlying accounting platform, it will be available from Codat with the same precision (up to a maximum of 9 decimal places).   For accounting platforms which do not provide an explicit currency rate, it is calculated as `baseCurrency / foreignCurrency` and will be returned to 9 decimal places.  ## Examples with base currency of GBP  | Foreign Currency | Foreign Amount | Currency Rate | Base Currency Amount (GBP) | | :--------------- | :------------- | :------------ | :------------------------- | | **USD**          | $20            | 0.781         | £15.62                     | | **EUR**          | €20            | 0.885         | £17.70                     | | **RUB**          | ₽20            | 0.011         | £0.22                      |  ## Examples with base currency of USD  | Foreign Currency | Foreign Amount | Currency Rate | Base Currency Amount (USD) | | :--------------- | :------------- | :------------ | :------------------------- | | **GBP**          | £20            | 1.277         | $25.54                     | | **EUR**          | €20            | 1.134         | $22.68                     | | **RUB**          | ₽20            | 0.015         | $0.30                      |, contactRef: map{id: str, contactType: str}, merchantName: str # Name of the merchant where the purchase took place, lines: [map{netAmount!: num, taxAmount!: num, taxRateRef: map, accountRef!: map, trackingRefs: [map]}] # Array of transaction lines., notes: str # Any private, company notes about the transaction.}\n@returns(202) {syncId: str} # Accepted\n@errors {400: The request made is not valid., 401: Your API request was not properly authorized., 404: One or more of the resources you referenced could not be found. This might be because your company or data connection id is wrong, or was already deleted., 422: The requests made can't be processed. This may be due to differences in platform support., 429: Too many requests were made in a given amount of time. Wait a short period and then try again.}\n\n@endpoint POST /companies/{companyId}/sync/expenses/syncs/{syncId}/transactions/{transactionId}/attachments\n@desc Upload attachment\n@returns(200) {companyId: str(uuid), id: str, transactionId: str} # OK\n@errors {400: The request made is not valid., 401: Your API request was not properly authorized., 404: One or more of the resources you referenced could not be found. This might be because your company or data connection id is wrong, or was already deleted., 429: Too many requests were made in a given amount of time. Wait a short period and then try again.}\n\n@end\n"}}