---
title: "Complete Signup With Code"
method: POST
path: "/api/v1/billing/trial-codes/complete-signup-with-code"
tags: ["trial-codes"]
---

# Complete Signup With Code

`POST /api/v1/billing/trial-codes/complete-signup-with-code`

## Request

- Base URL: `http://localhost:8000`
- URL: `http://localhost:8000/api/v1/billing/trial-codes/complete-signup-with-code`
- Auth: none declared

Complete signup for a user who signed up with a trial code.

TECH-657: Called AFTER Clerk authentication. Handles two cases:
1. User has no company yet: Creates company and subscription
2. User already has company (from Clerk webhook): Updates existing subscription

The Clerk webhook typically creates the company before this endpoint is called,
so case 2 is the common path. We check if the subscription is eligible for
trial code application (free_trial, trialing, or incomplete status).

Transaction Flow:
1. Validate code
2. Get or create company and subscription
3. Update subscription with target plan from code if specified
4. Record redemption
5. Commit only if ALL steps succeed

## Headers

- `Authorization` string

## Request body

- CompleteSignupWithCodeRequest: Request to complete signup with a trial code (TECH-657). Called AFTER Clerk authentication to create company and subscription.
  - `code` string, required: Trial code to redeem
  - `company_name` string, nullable: Optional company name. Defaults to email domain.

## Response `200`

Successful Response

- StandardResponse: Standard API response wrapper.
  - `success` boolean, required
  - `data` unknown
  - `message` string, nullable
  - `error` string, nullable
  - `meta` object, nullable

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/anomalyarmor/apis/anomalyarmor-api.md) · [All operations](https://skmtc.dev/anomalyarmor/apis/anomalyarmor-api/llms.txt) · [OpenAPI document](https://skmtc.dev/anomalyarmor/apis/anomalyarmor-api/revisions/51c755fb5d0b?raw)
