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

# Create Payment Term

> Create a new payment term with custom installment schedules

## Authorization

<ParamField header="Authorization" type="string" required>
  Bearer token for authentication. Format: `Bearer qwoty_your_token`
</ParamField>

## Request Body

<ParamField body="name" type="string" required>
  Name of the payment term (max 50 characters)
</ParamField>

<ParamField body="api_name" type="string" required>
  Unique API identifier (slug format, e.g., `net_30_days`)
</ParamField>

<ParamField body="reference" type="string">
  Internal reference code (max 50 characters)
</ParamField>

<ParamField body="is_active" type="boolean" default="true">
  Whether the payment term is active
</ParamField>

<ParamField body="id_crm" type="string">
  External CRM identifier
</ParamField>

<ParamField body="id_erp" type="string">
  External ERP identifier
</ParamField>

<ParamField body="id_accounting" type="string">
  External accounting system identifier
</ParamField>

<ParamField body="installments" type="array">
  Array of payment installments. Total percentage must equal 100%.

  <Expandable title="Installment Object">
    <ParamField body="name" type="string" required>
      Name of the installment
    </ParamField>

    <ParamField body="percentage" type="number" required>
      Percentage of total amount (0-100)
    </ParamField>

    <ParamField body="term" type="enum" required>
      Payment term type. Options: `due_now`, `due_on_receipt`, `net15`, `net30`, `net45`, `net60`, `net90`, `net120`, `eom30`, `eom45`, `eom60`, `po_received`, `custom`
    </ParamField>

    <ParamField body="custom_text" type="string">
      Custom text (required if term is `custom`)
    </ParamField>

    <ParamField body="order_number" type="number" required>
      Display order (1, 2, 3...)
    </ParamField>
  </Expandable>
</ParamField>

<Warning>
  The sum of all installment percentages must equal exactly 100%.
</Warning>

## Examples

<CodeGroup>
  ```bash Simple Payment (100% Net 30) theme={null}
  curl -X POST https://qwoty.app/api/payment-terms \
    -H "Authorization: Bearer qwoty_your_token" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Net 30 Days",
      "api_name": "net_30_days",
      "reference": "PT001",
      "is_active": true,
      "installments": [
        {
          "name": "Full Payment",
          "percentage": 100,
          "term": "net30",
          "order_number": 1
        }
      ]
    }'
  ```

  ```bash Split Payment (30% + 70%) theme={null}
  curl -X POST https://qwoty.app/api/payment-terms \
    -H "Authorization: Bearer qwoty_your_token" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "30% Deposit + 70% on Delivery",
      "api_name": "30_deposit_70_delivery",
      "reference": "PT002",
      "is_active": true,
      "installments": [
        {
          "name": "Deposit on Order",
          "percentage": 30,
          "term": "due_now",
          "order_number": 1
        },
        {
          "name": "Balance on Delivery",
          "percentage": 70,
          "term": "due_on_receipt",
          "order_number": 2
        }
      ]
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://qwoty.app/api/payment-terms', {
    method: 'POST',
    headers: {
      Authorization: 'Bearer qwoty_your_token',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      name: 'Net 30 Days',
      api_name: 'net_30_days',
      is_active: true,
      installments: [
        {
          name: 'Full Payment',
          percentage: 100,
          term: 'net30',
          order_number: 1,
        },
      ],
    }),
  })

  const data = await response.json()
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://qwoty.app/api/payment-terms',
      headers={
          'Authorization': 'Bearer qwoty_your_token',
          'Content-Type': 'application/json'
      },
      json={
          'name': 'Net 30 Days',
          'api_name': 'net_30_days',
          'is_active': True,
          'installments': [
              {
                  'name': 'Full Payment',
                  'percentage': 100,
                  'term': 'net30',
                  'order_number': 1
              }
          ]
      }
  )

  data = response.json()
  ```
</CodeGroup>

## Response

<ResponseField name="success" type="boolean">
  Indicates if the request was successful
</ResponseField>

<ResponseField name="data" type="object">
  The created payment term object

  <Expandable title="Payment Term Object">
    <ResponseField name="id" type="string">
      Unique identifier (UUID)
    </ResponseField>

    <ResponseField name="name" type="string">
      Payment term name
    </ResponseField>

    <ResponseField name="api_name" type="string">
      API identifier
    </ResponseField>

    <ResponseField name="reference" type="string">
      Internal reference
    </ResponseField>

    <ResponseField name="is_active" type="boolean">
      Active status
    </ResponseField>

    <ResponseField name="installments" type="array">
      Array of installment objects with id, name, percentage, term, and order\_number
    </ResponseField>

    <ResponseField name="created_at" type="string">
      ISO 8601 timestamp
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "success": true,
    "data": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Net 30 Days",
      "api_name": "net_30_days",
      "reference": "PT001",
      "is_active": true,
      "installments": [
        {
          "id": "660e8400-e29b-41d4-a716-446655440001",
          "name": "Full Payment",
          "percentage": 100,
          "term": "net30",
          "order_number": 1
        }
      ],
      "created_at": "2024-12-21T10:30:00Z"
    }
  }
  ```
</ResponseExample>

## Error Responses

<ResponseExample>
  ```json Validation Error theme={null}
  {
    "success": false,
    "error": "Installment percentages must sum to 100%"
  }
  ```

  ```json Duplicate API Name theme={null}
  {
    "success": false,
    "error": "Payment term with api_name 'net_30_days' already exists"
  }
  ```

  ```json Unauthorized theme={null}
  {
    "success": false,
    "error": "Invalid API token"
  }
  ```
</ResponseExample>
