Simulate a Direct Debit mandate outcome

Add MCP server to your AI tool

Allow AI tools and LLMs to interact with the API documentation portal through MCP.

MCP server URL

https://docs.getpenfold.dev/mcp

Standard setup for AI tools providing an mcp.json file

mcp.json
{
  "Penfold Payroll API v4 MCP server": {
    "url": "https://docs.getpenfold.dev/mcp"
  }
}

Close
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.

Path parameters

  • employer_id string Required

    The employer's id, as returned by GET /employers. This is not the employer's external_reference.

application/json

Body Required

  • outcome string Required

    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.

    Values are activated, failed, or cancelled.

Responses

  • 202

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

  • 400 application/json

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

    Hide response attributes Show response attributes object
    • error string

      A descriptive error message.

    • validation_errors array[object]
      Hide validation_errors attributes Show validation_errors attributes object
      • field string Required

        The name of the field that failed validation.

      • message string Required

        A descriptive error message.

  • 401 application/json

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

    Hide response attribute Show response attribute object
    • error string

      A descriptive error message.

  • 404 application/json

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

    Hide response attribute Show response attribute object
    • error string

      A descriptive error message.

  • 405 application/json

    Method not allowed.

    Hide response attribute Show response attribute object
    • error string

      A descriptive error message.

  • 409 application/json

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

    Hide response attributes Show response attributes object
    • code string Required

      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.

      Values are NoDirectDebitMandate or MandateStateNotSupported.

    • error string Required
POST /sandbox/employers/{employer_id}/direct_debit_mandate
curl \
 --request POST 'https://payroll-api.getpenfold.dev/v4/sandbox/employers/{employer_id}/direct_debit_mandate' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/json" \
 --data '{
  "outcome": "activated"
}'
Request examples
{
  "outcome": "activated"
}
Response examples (400)
{
  "error": "Bad request: invalid data provided.",
  "validation_errors": [
    {
      "field": "email",
      "message": "Email address is invalid."
    }
  ]
}
Response examples (401)
{
  "error": "Bad request: invalid data provided."
}
Response examples (404)
{
  "error": "Bad request: invalid data provided."
}
Response examples (405)
{
  "error": "Bad request: invalid data provided."
}
Response examples (409)
{
  "code": "NoDirectDebitMandate",
  "error": "the employer has no Direct Debit mandate"
}