Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.credibill.tech/docs/llms.txt

Use this file to discover all available pages before exploring further.

This example shows how to perform the same flow using raw HTTP requests with cURL. This is useful for testing or for languages without an official SDK.

1. Create Customer

// app/api/customers/route.ts
import { NextResponse } from "next/server";

export async function POST(request: Request) {
  const body = await request.json();
  const res = await fetch(
    "https://giant-goldfish-922.convex.site/api/customers",
    {
      method: "POST",
      headers: {
        Authorization: `Bearer ${process.env.CREDIBILL_SECRET_KEY}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify(body),
    }
  );
  return NextResponse.json(await res.json(), { status: res.status });
}
Response:
{
  "id": "cus_12345",
  "email": "customer@example.com",
  "name": "Startup Inc",
  "created": 1678900000
}

2. Create Subscription

Take the id from the previous response (e.g., cus_12345) and use it to create a subscription.
// app/api/subscriptions/route.ts
import { NextResponse } from "next/server";

export async function POST(request: Request) {
  const body = await request.json();
  const res = await fetch(
    "https://giant-goldfish-922.convex.site/api/subscriptions",
    {
      method: "POST",
      headers: {
        Authorization: `Bearer ${process.env.CREDIBILL_SECRET_KEY}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify(body),
    }
  );
  return NextResponse.json(await res.json(), { status: res.status });
}
Response:
{
  "id": "sub_67890",
  "status": "active",
  "current_period_end": 1681578400,
  "customer": "cus_12345",
  "plan": {
    "id": "plan_starter_monthly",
    "amount": 2900
  }
}