Skip to main content
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"

curl --location --request POST "$LAGO_URL/api/v1/subscriptions" \
  --header "Authorization: Bearer $API_KEY" \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "subscription": {
    "external_customer_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
    "plan_code": "premium",
    "name": "Repository A",
    "external_id": "my_sub_1234567890",
    "billing_time": "anniversary",
    "ending_at": "2022-10-08T00:00:00Z",
    "subscription_at": "2022-08-08T00:00:00Z",
    "plan_overrides": {
      "amount_cents": 10000,
      "amount_currency": "USD",
      "description": "Plan for early stage startups.",
      "invoice_display_name": "Startup plan",
      "name": "Startup",
      "tax_codes": [
        "french_standard_vat"
      ],
      "trial_period": 5,
      "charges": [
        {
          "id": "cha_12345",
          "billable_metric_id": "bm_12345",
          "invoice_display_name": "Setup",
          "min_amount_cents": 0,
          "tax_codes": [
            "standard_vat"
          ],
          "properties": {
            "graduated_ranges": [
              {
                "from_value": 0,
                "to_value": 10,
                "flat_amount": "10",
                "per_unit_amount": "0.5"
              }
            ]
          }
        },
        {
          "id": "cha_67890",
          "billable_metric_id": "bm_67890",
          "invoice_display_name": "FX Transfer",
          "min_amount_cents": 0,
          "properties": {
            "graduated_percentage_ranges": [
              {
                "from_value": 0,
                "to_value": 10,
                "rate": "1",
                "flat_amount": "10"
              }
            ]
          }
        },
        {
          "id": "cha_111213",
          "billable_metric_id": "bm_111213",
          "invoice_display_name": "API calls",
          "min_amount_cents": 0,
          "properties": {
            "amount": "30",
            "free_units": 100,
            "package_size": 1000
          }
        },
        {
          "id": "cha_141516",
          "billable_metric_id": "bm_141516",
          "invoice_display_name": "Interchange",
          "min_amount_cents": 0,
          "properties": {
            "rate": "1",
            "fixed_amount": "0.5",
            "free_units_per_events": 5,
            "free_units_per_total_aggregation": "500",
            "per_transaction_max_amount": "3.75",
            "per_transaction_min_amount": "1.75"
          }
        },
        {
          "id": "cha_171819",
          "billable_metric_id": "bm_171819",
          "invoice_display_name": "Seats",
          "min_amount_cents": 0,
          "properties": {
            "volume_ranges": [
              {
                "from_value": 0,
                "to_value": 10,
                "flat_amount": "10",
                "per_unit_amount": "0.5"
              }
            ]
          }
        },
        {
          "id": "cha_202122",
          "billable_metric_id": "bm_202122",
          "invoice_display_name": "Interchange",
          "min_amount_cents": 0,
          "filters": [
            {
              "values": {
                "cloud": ["aws"],
                "region": ["us-east-1"]
              },
              "properties": {
                "graduated_ranges": [
                  {
                    "from_value": 0,
                    "to_value": 10,
                    "flat_amount": "10",
                    "per_unit_amount": "0.5"
                  }
                ]
              }
            }
          ]
        }
      ]
    }
  }
}'