> ## Documentation Index
> Fetch the complete documentation index at: https://docs.decodahealth.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Embed Payment Config

> Create a payin configuration for an embedded payment component.

This is a public endpoint that allows external websites to create
payment configurations for collecting payments from patients.

Args:
    patient_id: The patient's ID
    amount_cents: The payment amount in cents
    is_surcharged: Whether to apply surcharge fees (default: True, uses tenant settings)

Creates a payin configuration for the embedded payment component. Use this when your website needs to collect a payment from a patient inside an iframe.

## Two modes

### Simple amount

Pass `amount_cents` for a single, flat payment. The embed shows a "Custom Amount" line item.

```
POST /billing/embed-payment/{patient_id}?amount_cents=5000&is_surcharged=true
```

### Itemized charge (items and discounts)

Pass `charge_id` to use a pre-created charge with line items, discounts, and taxes. The embed displays the full charge breakdown.

```
POST /billing/embed-payment/{patient_id}?charge_id=chg_xxx&is_surcharged=true
```

You must create the charge first via the [Create Charge](/api-reference/provider/create-charge) or [Convert Cart to Charge](/api-reference/provider/convert-cart-to-charge) API. See [Payment Embed: Itemized Charges](/api-reference/guides/embed-payment-itemized-charges) for the full flow.

## Embed URL parameters

The embed page (`/embed/pay/{patientId}`) accepts these query parameters:

| Parameter                             | Description                                                                             |
| ------------------------------------- | --------------------------------------------------------------------------------------- |
| `amount`                              | Payment amount in cents (required when `charge_id` is not used)                         |
| `charge_id` or `chargeId`             | Pre-created charge ID for itemized charges                                              |
| `allowedMethods` or `allowed_methods` | Comma-separated payment methods: `CARD`, `ACH`, `APPLE_PAY`. Use `CARD` to disable ACH. |
| `theme`                               | `light` or `dark`                                                                       |
| `showSummary`                         | `true` (default) or `false` to hide the payment summary header                          |

## Response

When `charge_id` is used, the response includes a `charge` object with `items`, `totalOutstanding`, and `totalDiscount` for display in your UI.


## OpenAPI

````yaml post /billing/embed-payment/{patient_id}
openapi: 3.1.0
info:
  title: Decoda API
  description: External API documentation for the Decoda Health platform.
  version: '1.0'
servers: []
security: []
paths:
  /billing/embed-payment/{patient_id}:
    post:
      tags:
        - provider
        - billing
        - public
      summary: Create Embed Payment Config
      description: |-
        Create a payin configuration for an embedded payment component.

        This is a public endpoint that allows external websites to create
        payment configurations for collecting payments from patients.

        Args:
            patient_id: The patient's ID
            amount_cents: The payment amount in cents
            is_surcharged: Whether to apply surcharge fees (default: True, uses tenant settings)
      operationId: create_embed_payment_config_billing_embed_payment__patient_id__post
      parameters:
        - name: TENANT
          in: header
          required: true
          schema:
            type: string
            title: Tenant
          description: The tenant you are making this request on behalf of
        - name: API-KEY
          in: header
          required: true
          schema:
            type: string
            title: Api-Key
          description: Your api key
        - name: patient_id
          in: path
          required: true
          schema:
            type: string
            title: Patient Id
        - name: amount_cents
          in: query
          required: true
          schema:
            type: integer
            title: Amount Cents
        - name: is_surcharged
          in: query
          required: false
          schema:
            type: boolean
            default: true
            title: Is Surcharged
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmbedPaymentConfig'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    EmbedPaymentConfig:
      properties:
        sessionKey:
          type: string
          title: Sessionkey
        payinConfigId:
          type: string
          title: Payinconfigid
        sandbox:
          type: boolean
          title: Sandbox
        patient:
          $ref: '#/components/schemas/PublicPatient'
        fee:
          type: integer
          title: Fee
          default: 0
      type: object
      required:
        - sessionKey
        - payinConfigId
        - sandbox
        - patient
      title: EmbedPaymentConfig
      description: Response schema for embed payment configuration.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    PublicPatient:
      properties:
        id:
          type: string
          title: Id
        firstName:
          type: string
          title: Firstname
        lastName:
          anyOf:
            - type: string
            - type: 'null'
          title: Lastname
      type: object
      required:
        - id
        - firstName
        - lastName
      title: PublicPatient
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````