<!-- Generated by scripts/build-docs.js. Edit docs/swagger.yaml or docs/guides/, then run `npm run docs:build`. -->

# Save journal entry IDs for one-time payments

`PATCH https://marketplace-api.sequifi.com/v1/one-time-payments`

Module: Payroll · operationId: `updateOneTimePaymentJournalIds` · Auth: `Authorization: Bearer <token>`
Web page: https://apidocs.sequifi.com/#/api/update-one-time-payment-journal-ids

Saves a journal entry id on paid one-time payments, so they drop out of GET /v1/one-time-payments?quickbooks_synced=false. Send a JSON array of 1 to 500 items keyed by `one_time_payment_id`. A different id sent for a payment that already has one replaces it without warning.

**Before you call:**

- Take payments from GET /v1/one-time-payments?quickbooks_synced=false and create their journal entries first.
- Use `one_time_payment_id`. Never send a `payroll_id` here: the two are different number series. Pay runs are saved with PATCH /v1/payroll-history.

**What happens:**

- All items are saved in one transaction: either every item is applied or none is.
- Any existing journal entry id is overwritten.
- A `one_time_payment_id` with no one-time payment is listed in `data.not_found`. This is not an error.
- `data.updated` counts items, not records. An item sent twice counts twice.

**Idempotency and retries:**

- Sending the same id again is safe and changes nothing.
- Sending a new id replaces the old one, which leaves the earlier journal entry orphaned in your books. Check that `quickbooks_journal_entry_id` is null before you create an entry.
- After a batch, query GET /v1/one-time-payments?quickbooks_synced=false again from page 1.

**Formats:**

- `one_time_payment_id` must be a JSON integer. A string such as `"14"` is rejected.
- `quickbooks_journal_entry_id` must be a non-blank string, from any accounting system. Leading and trailing spaces are trimmed.

**Errors:**

- `400 Request body must be a non-empty array of { one_time_payment_id, quickbooks_journal_entry_id }`: the body is not a JSON array, is empty, or is not valid JSON.
- `400 Batch size exceeds 500 items — split into multiple requests`.
- `400 Validation failed`: `data.errors` lists each bad item by index, for example `"[0]: one_time_payment_id must be a positive integer"`. Nothing is saved.

**Related:**

- GET /v1/one-time-payments lists paid one-time payments and their `quickbooks_journal_entry_id`.

## Request body

- `one_time_payment_id` (integer, **required**): The payment's `one_time_payment_id` from GET /v1/one-time-payments. Must be a JSON integer. Minimum: 1. Example: `14`.
- `quickbooks_journal_entry_id` (string, **required**): Journal entry id from your accounting system. Example: `JE-1042`.

Example

```json
[
  {
    "one_time_payment_id": 14,
    "quickbooks_journal_entry_id": "JE-1042"
  },
  {
    "one_time_payment_id": 32,
    "quickbooks_journal_entry_id": "JE-1043"
  }
]
```

## Example request

```bash
curl -X PATCH "https://marketplace-api.sequifi.com/v1/one-time-payments" \
  -H "Authorization: Bearer $SEQUIFI_TOKEN" \
  -H "Content-Type: application/json" \
  -d '[{"one_time_payment_id":14,"quickbooks_journal_entry_id":"JE-1042"},{"one_time_payment_id":32,"quickbooks_journal_entry_id":"JE-1043"}]'
```

## Responses

### 200: Batch saved. Check `not_found` for ids with no one-time payment.

- `status` (integer): The HTTP status code, repeated. Example: `200`.
- `message` (string): Short text. Wording varies by endpoint; branch on the HTTP status, not on this text. Example: `success`.
- `data` (object)
  - `requestedBy` (string): Label of the API credential that made the call.
  - `updated` (integer): Number of items that matched a one-time payment.
  - `not_found` (array of integer): `one_time_payment_id` values with no one-time payment.

```json
{
  "status": 200,
  "message": "quickbooks_journal_entry_id saved",
  "data": {
    "requestedBy": "acme",
    "updated": 2,
    "not_found": []
  }
}
```

### 400: Invalid request body

Example (not_array): Body is not a non-empty array

```json
{
  "status": 400,
  "message": "Request body must be a non-empty array of { one_time_payment_id, quickbooks_journal_entry_id }",
  "data": {}
}
```

### 401: Missing, invalid or expired token. The gateway rejects the call before it reaches Sequifi, so the body has only a `message`.

```json
{
  "message": "Unauthorized"
}
```

### 500: Internal server error. Nothing in the batch was saved.

```json
{
  "status": 500,
  "message": "Internal Server Error",
  "data": {}
}
```
