> ## Documentation Index
> Fetch the complete documentation index at: https://docs.useautumn.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Trial - card not required

> Enable a trial period that customers can access without providing payment information

Card-not-required trials give customers full access to a paid plan for a limited time without requiring payment information upfront. Customers can optionally add a payment method during the trial to continue using the plan after it expires.

After the trial period, if no payment method is provided, customers lose access to the plan. If they add a payment method, billing begins automatically when the trial ends.

Companies using this model include Cursor, Greptile and Vercel.

## Configure Pricing

You can toggle on a trial for a plan when creating it, or in the "plan settings" section. Switch off the "card required" flag.

<Frame style={{ width: "400px" }}>
  <img src="https://mintcdn.com/autumn-b9b4c0fb/df8oGyhsA_ngL7c4/assets/guides/trial-card-not-required/no-card-light.png?fit=max&auto=format&n=df8oGyhsA_ngL7c4&q=85&s=1bb952f2661d7f40a36d76e24b68491c" className="block dark:hidden" width="872" height="684" data-path="assets/guides/trial-card-not-required/no-card-light.png" />

  <img src="https://mintcdn.com/autumn-b9b4c0fb/df8oGyhsA_ngL7c4/assets/guides/trial-card-not-required/no-card-dark.png?fit=max&auto=format&n=df8oGyhsA_ngL7c4&q=85&s=a905e2784169ca152f5daa89c5b50d7a" className="hidden dark:block" width="870" height="668" data-path="assets/guides/trial-card-not-required/no-card-dark.png" />
</Frame>

<Note>
  The "card required" flag will only be visible if the plan is a paid plan. However, you can also add a limited-time trial to a free plan.

  This is similar to a card-not-required trial, but there will be no automatic billing when the trial ends. Instead, you can manually `attach` the plan to the customer to bill them.
</Note>

<Accordion title="Auto-enabling the trial plan">
  Since no card is required, you can choose whether the plan is enabled automatically when a customer is created, or if you want to manually attach the plan to a customer (eg, when they opt-in to the trial).

  If you switch the "auto-enable" flag to true, the trial plan will be automatically applied to newly created customers. The plan will be labelled as an `auto-trial` plan. Customers will only be able to access this trial once.

  You can also create another `free` `auto-enable` plan without a trial. This will be enabled if the customer does not add a payment method during the trial, or if they cancel their plan later on.

  <Frame>
    <img src="https://mintcdn.com/autumn-b9b4c0fb/df8oGyhsA_ngL7c4/assets/guides/trial-card-not-required/auto-trial-light.png?fit=max&auto=format&n=df8oGyhsA_ngL7c4&q=85&s=42a81bbbbf50f67c8325d4c5dac39408" className="block dark:hidden" width="1624" height="378" data-path="assets/guides/trial-card-not-required/auto-trial-light.png" />

    <img src="https://mintcdn.com/autumn-b9b4c0fb/df8oGyhsA_ngL7c4/assets/guides/trial-card-not-required/auto-trial-dark.png?fit=max&auto=format&n=df8oGyhsA_ngL7c4&q=85&s=dd95eaec5f619ace17dde3562f8459f3" className="hidden dark:block" width="1626" height="368" data-path="assets/guides/trial-card-not-required/auto-trial-dark.png" />
  </Frame>
</Accordion>

## Implementation

#### Enabling the trial

Attach the plan to the customer to enable the trial. Since no card is required, no checkout is needed.

If you switched the "auto-enable" flag to true, you can skip the attach step as the trial will be automatically applied to newly created customers.

<CodeGroup>
  ```tsx React theme={null}
  import { useCustomer } from "autumn-js/react";

  const { attach } = useCustomer();

  const handleStartTrial = async () => {
    await attach({ planId: "pro" });
    console.log("Trial started");
  };

  <Button onClick={handleStartTrial}>Start Trial</Button>;
  ```

  ```typescript TypeScript theme={null}
  import { Autumn } from "autumn-js";

  const autumn = new Autumn({ secretKey: "am_sk_test_1234" });

  const response = await autumn.billing.attach({
    customerId: "user_123",
    planId: "pro",
  });

  // For card-not-required trials, paymentUrl may be null
  // if the trial is enabled without requiring payment
  ```

  ```python Python theme={null}
  from autumn_sdk import Autumn

  autumn = Autumn("am_sk_test_1234")

  response = await autumn.billing.attach(
      customer_id="user_123",
      plan_id="pro",
  )
  ```

  ```bash cURL theme={null}
  curl -X POST "https://api.useautumn.com/v1/attach" \
    -H "Authorization: Bearer am_sk_test_1234" \
    -H "Content-Type: application/json" \
    -d '{
      "customer_id": "user_123",
      "plan_id": "pro"
    }'
  ```
</CodeGroup>

<Check>
  The trial will only be applied once per customer.
</Check>

#### Adding a payment method

Customers can add a payment method and transition to the paid version of the plan using the setup payment endpoint. Once the trial ends, they will be charged for the plan.

If the customer does not add a payment method, the trial will expire and they will lose access to the plan.

<CodeGroup>
  ```tsx React theme={null}
  import { useCustomer } from "autumn-js/react";

  const { setupPayment } = useCustomer();

  <Button onClick={() => setupPayment()}>
    Add Payment Method
  </Button>;
  ```

  ```typescript TypeScript theme={null}
  import { Autumn } from "autumn-js";

  const autumn = new Autumn({ secretKey: "am_sk_test_1234" });

  const response = await autumn.billing.setupPayment({
    customerId: "user_123",
    successUrl: "https://your-app.com/success",
  });

  redirect(response.url);
  ```

  ```python Python theme={null}
  from autumn_sdk import Autumn

  autumn = Autumn("am_sk_test_1234")

  response = await autumn.billing.setup_payment(
      customer_id="user_123",
      success_url="https://your-app.com/success",
  )
  # Redirect to response.url
  ```

  ```bash cURL theme={null}
  curl -X POST "https://api.useautumn.com/v1/billing.setup_payment" \
    -H "Authorization: Bearer am_sk_test_1234" \
    -H "Content-Type: application/json" \
    -d '{
      "customer_id": "user_123",
      "success_url": "https://your-app.com/success"
    }'
  ```
</CodeGroup>

<Expandable title="hosted setup payment page">
  <Frame>
    <img src="https://mintcdn.com/autumn-b9b4c0fb/df8oGyhsA_ngL7c4/assets/guides/trial-card-not-required/setup-payment.png?fit=max&auto=format&n=df8oGyhsA_ngL7c4&q=85&s=3d76a97a189c25414ca11128c6d81010" width="1588" height="1456" data-path="assets/guides/trial-card-not-required/setup-payment.png" />
  </Frame>
</Expandable>

<Tip>
  If there's a payment method on file, the customer will be charged. Otherwise, the trial plan will expire. If there's another non-trial auto-enable plan (like a free tier), it will be automatically enabled.
</Tip>

#### Ending the trial early

You can end the trial early by cancelling the plan immediately, and attaching it again. You may want to pass in a `reward` into the attach request to give the customer a discount for upgrading early.

<Warning>
  Make sure to warn the user that this action will cancel their current trial before proceeding.
</Warning>

<CodeGroup>
  ```tsx React theme={null}
  import { useCustomer } from "autumn-js/react";

  const { updateSubscription, attach } = useCustomer();

  const handleEarlyEnd = async () => {
    // Cancel the trial immediately
    await updateSubscription({
      planId: "pro",
      cancelAction: "cancel_immediately",
    });
    
    // Attach the plan again with a reward
    await attach({
      planId: "pro",
      reward: "early_end",
    });
      
    console.log("Trial ended early");
  };

  <Button onClick={handleEarlyEnd}>Upgrade Now</Button>;
  ```

  ```typescript TypeScript theme={null}
  import { Autumn } from "autumn-js";

  const autumn = new Autumn({ secretKey: "am_sk_test_1234" });

  // Cancel the trial immediately
  await autumn.billing.update({
    customerId: "user_123",
    planId: "pro",
    cancelAction: "cancel_immediately",
  });

  // Attach the plan again with a reward
  const response = await autumn.billing.attach({
    customerId: "user_123",
    planId: "pro",
    reward: "early_end",
  });

  console.log("Trial ended early");
  ```

  ```python Python theme={null}
  from autumn_sdk import Autumn

  autumn = Autumn("am_sk_test_1234")

  # Cancel the trial immediately
  await autumn.billing.update(
      customer_id="user_123",
      plan_id="pro",
      cancel_action="cancel_immediately",
  )

  # Attach the plan again with a reward
  response = await autumn.billing.attach(
      customer_id="user_123",
      plan_id="pro",
      reward="early_end",
  )

  print("Trial ended early")
  ```

  ```bash cURL theme={null}
  # Cancel the trial immediately
  curl -X POST "https://api.useautumn.com/v1/billing/update" \
    -H "Authorization: Bearer am_sk_test_1234" \
    -H "Content-Type: application/json" \
    -d '{
      "customer_id": "user_123",
      "plan_id": "pro",
      "cancel_action": "cancel_immediately"
    }'

  # Attach the plan again with a reward
  curl -X POST "https://api.useautumn.com/v1/attach" \
    -H "Authorization: Bearer am_sk_test_1234" \
    -H "Content-Type: application/json" \
    -d '{
      "customer_id": "user_123",
      "plan_id": "pro",
      "reward": "early_end"
    }'
  ```
</CodeGroup>

***
