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

# Update Payment Term

> Update an existing payment term

## Authorization

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

## Path Parameters

<ParamField path="id" type="string" required>
  UUID of the payment term to update
</ParamField>

## Request Body

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

<ParamField body="api_name" type="string">
  Unique API identifier (slug format)
</ParamField>

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

<ParamField body="is_active" type="boolean">
  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. If provided, replaces all existing installments.

  <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
    </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>

<Info>
  You can update individual fields or the entire payment term. Omitted fields
  remain unchanged.
</Info>

<Warning>
  If updating installments, the sum of all percentages must equal 100%.
</Warning>

## Examples

<CodeGroup>
  ```bash Update Name Only theme={null}
  curl -X PUT https://qwoty.app/api/payment-terms/550e8400-e29b-41d4-a716-446655440000 \
    -H "Authorization: Bearer qwoty_your_token" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Net 30 Days (Updated)"
    }'
  ```

  ```bash Update Status theme={null}
  curl -X PUT https://qwoty.app/api/payment-terms/550e8400-e29b-41d4-a716-446655440000 \
    -H "Authorization: Bearer qwoty_your_token" \
    -H "Content-Type: application/json" \
    -d '{
      "is_active": false
    }'
  ```

  ```bash Update Complete Payment Term theme={null}
  curl -X PUT https://qwoty.app/api/payment-terms/550e8400-e29b-41d4-a716-446655440000 \
    -H "Authorization: Bearer qwoty_your_token" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "50% Deposit + 50% Net 30",
      "api_name": "50_deposit_50_net30",
      "installments": [
        {
          "name": "Deposit",
          "percentage": 50,
          "term": "due_now",
          "order_number": 1
        },
        {
          "name": "Balance",
          "percentage": 50,
          "term": "net30",
          "order_number": 2
        }
      ]
    }'
  ```

  ```javascript JavaScript theme={null}
  const paymentTermId = '550e8400-e29b-41d4-a716-446655440000'

  const response = await fetch(
    `https://qwoty.app/api/payment-terms/${paymentTermId}`,
    {
      method: 'PUT',
      headers: {
        Authorization: 'Bearer qwoty_your_token',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        name: 'Net 30 Days (Updated)',
        is_active: true,
      }),
    },
  )

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

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

  payment_term_id = '550e8400-e29b-41d4-a716-446655440000'

  response = requests.put(
      f'https://qwoty.app/api/payment-terms/{payment_term_id}',
      headers={
          'Authorization': 'Bearer qwoty_your_token',
          'Content-Type': 'application/json'
      },
      json={
          'name': 'Net 30 Days (Updated)',
          'is_active': True
      }
  )

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

## Response

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

<ResponseField name="data" type="object">
  The updated payment term object with all fields
</ResponseField>

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

## Error Responses

<ResponseExample>
  ```json Not Found theme={null}
  {
    "success": false,
    "error": "Payment term not found"
  }
  ```

  ```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>
