# Calculate credit operation (/docs/api-reference/reseller/calculateCreditOperation)

> Preview the cost of a transfer or revert without moving any credits. Use this to confirm amounts before calling the transfer or revert endpoints. The response shape differs between forward transfers and reverts. See the examples.



> **Reseller accounts only.** [Request access](https://omnidim.io/contact-us?reason=partnership\&lock=1).

**POST** `/reseller/credits/calculate`

Preview the cost of a transfer or revert without moving any
credits. Use this to confirm amounts before calling the
transfer or revert endpoints. The response shape differs
between forward transfers and reverts. See the examples.

```yaml
operationId: calculateCreditOperation
requestBody:
  required: true
  content:
    application/json:
      schema:
        type: object
        required:
          - minutes
        properties:
          minutes:
            type: integer
            description: Number of minutes to calculate for.
          cost_per_min:
            type: number
            description: >-
              Rate per minute for a forward transfer (e.g. `0.20`). Not required when `is_revert` is
              `true`.
            example: 0.2
          is_revert:
            type: boolean
            description: Set to `true` to calculate a revert instead of a forward transfer.
            default: false
          child_organization_id:
            type: integer
            description: >-
              ID of the child organization to revert credits from. Required when `is_revert` is
              `true`.
      examples:
        forward:
          summary: Forward transfer calculation
          value:
            minutes: 500
            cost_per_min: 0.2
        revert:
          summary: Revert calculation
          value:
            minutes: 10
            is_revert: true
            child_organization_id: 4002
responses:
  '200':
    description: Calculated outcome.
    content:
      application/json:
        schema:
          type: object
          properties:
            success:
              type: boolean
            my_cost:
              type: number
              description: Forward only. Amount deducted from the reseller balance.
            user_credit:
              type: number
              description: Forward only. Credit value the child receives at `cost_per_min`.
            profit:
              type: number
              description: Forward only. `user_credit - my_cost`.
            margin:
              type: number
              description: Forward only. Per-minute margin.
            reseller_balance:
              type: number
              description: Forward only. Current reseller balance before the transfer.
            reseller_available_minutes:
              type: integer
              description: Forward only. Minutes the reseller could still transfer at its own rate.
            new_reseller_balance:
              type: number
              description: Forward only. Reseller balance after the proposed transfer.
            refund_amount:
              type: number
              description: Revert only. Credits added back to the reseller.
            deduction_amount:
              type: number
              description: Revert only. Credits removed from the child at its current rate.
            child_balance:
              type: number
              description: Revert only. Child balance before the revert.
            child_available_minutes:
              type: integer
              description: Revert only. Minutes available in the child's balance.
            new_child_balance:
              type: number
              description: Revert only. Child balance after the proposed revert.
            reseller_rate:
              type: number
              description: Reseller's wholesale rate (cost per minute).
            currency_symbol:
              type: string
        examples:
          forward:
            summary: Forward transfer (500 min at $0.20/min)
            value:
              success: true
              my_cost: 45
              user_credit: 50
              profit: 5
              margin: 0.01
              reseller_rate: 0.09
              reseller_balance: 66.113
              reseller_available_minutes: 734
              new_reseller_balance: 21.113
              currency_symbol: $
          revert:
            summary: Revert (10 min from a child)
            value:
              success: true
              refund_amount: 0.9
              deduction_amount: 2
              reseller_rate: 0.09
              child_balance: 10
              child_available_minutes: 50
              new_child_balance: 8
              currency_symbol: $
```

**curl**

```bash
curl -X POST "https://backend.omnidim.io/api/v1/reseller/credits/calculate" \
  -H "Authorization: Bearer $OMNIDIM_API_KEY"
```
