Skip to main content
POST
/
credits
/
createPrepaidGrant
Create a prepaid credit grant
curl --request POST \
  --url https://api.metronome.com/v1/credits/createPrepaidGrant \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "customer_id": "9b85c1c1-5238-4f2a-a409-61412905e1e1",
  "grant_amount": {
    "amount": 1000,
    "credit_type_id": "5ae401dc-a648-4b49-9ac3-391bb5bc4d7b"
  },
  "name": "Acme Corp Promotional Credit Grant",
  "reason": "Incentivize new customer",
  "effective_at": "2022-02-01T00:00:00Z",
  "invoice_date": "2022-02-01T00:00:00Z",
  "expires_at": "2022-04-01T00:00:00Z",
  "paid_amount": {
    "amount": 5000,
    "credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2"
  },
  "priority": 0.5,
  "prepaid_options": {
    "billing_provider_type": "stripe",
    "stripe_options": {
      "calculate_tax": true,
      "redirect_url": "https://example.com/action_required_redirect",
      "invoice_custom_fields": [
        {
          "name": "x_account_id",
          "value": "KyVnHhSBWl7eY2bl"
        }
      ],
      "invoice_metadata": {
        "ex_metadata1": "metadata value 1",
        "ex_metadata22": "metadata value 2"
      }
    }
  },
  "credit_grant_type": "enterprise"
}'
{
  "data": {
    "id": "8b24d3dc-6db5-432d-9416-8439b3fbf242",
    "billing_provider_payment": {
      "billing_provider_type": "stripe",
      "stripe_payment_info": {
        "invoice_id": "in_1J5Z2n2eZvKYlo2C0Z1Z2n2e",
        "payment_status": "requires_action",
        "target_redirect_url": "https://example.com/action_required_redirect",
        "next_action_type": "redirect_to_url"
      }
    }
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

The details of the credit grant to create.

customer_id
string<uuid>
required

the Metronome ID of the customer

grant_amount
object
required

the amount of credits granted

paid_amount
object
required

the amount paid for this credit grant; must be greater than 0

name
string
required

the name of the credit grant as it will appear on invoices

expires_at
string<date-time>
required

The credit grant will only apply to usage or charges dated before this timestamp

invoice_date
string<date-time>
required

The date to issue an invoice for the paid_amount.

priority
number
required
prepaid_options
object
required

Options for prepaid credits. If specified, the credits will not be released until payment is received.

effective_at
string<date-time>

The credit grant will only apply to usage or charges dated on or after this timestamp

reason
string

Reason for the credit grant. This may be shown to your users.

credit_grant_type
string

Internal-only identifier used to categorize your credit grant. Your users won't see this.

product_ids
string<uuid>[]

The product(s) which these credits will be applied to. (If unspecified, the credits will be applied to charges for all products.). The array ordering specified here will be used to determine the order in which credits will be applied to invoice line items

Response

Success

data
object
required
I