> For the complete documentation index, see [llms.txt](https://docs.getpenfold.dev/llms.txt)

# Simulate a Direct Debit mandate outcome

> POST /sandbox/employers/{employer_id}/direct_debit_mandate
> 
> **Sandbox only, not available in production.** In production this route returns `404 Not Found`.
> 
> **Partner organisations only.** A Payroll organisation calling this endpoint receives `405 Method Not Allowed`.
> 
> Ask GoCardless’s sandbox to move the employer’s Direct Debit mandate to the given outcome. Penfold does not change the mandate status itself. GoCardless sends its usual webhook, and `direct_debit_mandate_status` on `GET /employers/{employer_id}` changes once Penfold has processed it. The simulation skips the wait for the bank, so the status changes much sooner than it would in production.



## Servers
- https://payroll-api.getpenfold.dev/v4: https://payroll-api.getpenfold.dev/v4


## Authentication methods
- O auth2 client credentials


## Parameters

### Path parameters

- **employer_id** (string)
  The employer's `id`, as returned by `GET /employers`. This is not the employer's `external_reference`.



### Body: application/json (object)

- **outcome** (string)
  The mandate outcome to simulate. Each outcome needs the mandate to be in a certain status first. `activated` needs `PendingSubmission` and moves the mandate to `Active`. `failed` needs `PendingSubmission` or `Submitted` and moves the mandate to `Failed`. `cancelled` needs any status except `Cancelled`, and cancels the mandate in GoCardless, which moves it to `Cancelled`.



## Responses
### 202
GoCardless accepted the simulation. The mandate status changes when its webhook is processed.

### 400
Bad request, the request is malformed or contains invalid data.

#### Body: application/json (object)
- **error** (string)
  A descriptive error message.

- **validation_errors** (array[object])


### 401
Unauthorized, the request requires authentication, and the provided credentials are either missing or incorrect.

#### Body: application/json (object)
- **error** (string)
  A descriptive error message.


### 404
Employer not found, the specified employer_id does not match any employer your organisation can access. Also returned in production.

#### Body: application/json (object)
- **error** (string)
  A descriptive error message.


### 405
Method not allowed.

#### Body: application/json (object)
- **error** (string)
  A descriptive error message.


### 409
The simulation cannot run for this employer. The `code` field says why.

#### Body: application/json (object)
- **code** (string)
  Use this field, rather than `error`, to distinguish between 409 responses.
  `NoDirectDebitMandate` means the employer has no Direct Debit mandate to simulate an outcome on.
  `MandateStateNotSupported` means the mandate’s current status does not allow the requested outcome, for example `activated` on a mandate that is already `Active`. The `error` message names the mandate’s current status and either the status the outcome needs or that GoCardless refused the outcome. To simulate again on a new mandate, start a new Direct Debit session with `POST /employers/{employer_id}/direct-debit-sessions`.

- **error** (string)



[Powered by Bump.sh](https://bump.sh)
