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

# Quickstart

> Start building with the Contazen API in under 5 minutes

## Setup your development environment

Get your API key and make your first API call in minutes.

<Steps>
  <Step title="Create a Contazen account">
    Sign up for a free account at [app.contazen.ro](https://app.contazen.ro/register) if you don't have one already.
  </Step>

  <Step title="Set up your company details">
    Complete your company profile in the dashboard:

    1. Navigate to [Company Settings](https://app.contazen.ro/firm/index/update)
    2. Fill in your company details:
       * Company name and legal information (CUI, RC)
       * Address and contact information
       * Bank account details (for invoices)
       * Logo and branding

    <Warning>
      Complete company setup is required before creating invoices.
    </Warning>
  </Step>

  <Step title="Get your API key">
    Navigate to [Settings → API Keys](https://app.contazen.ro/settings/api-keys) in your dashboard to create your API key.

    <Note>
      You'll receive a **Live key** (`sk_live_...`) for production use. Store it securely - it won't be shown again.
    </Note>
  </Step>

  <Step title="Make your first API call">
    Test your setup by listing your clients:

    <CodeGroup>
      ```bash cURL theme={null}
      curl https://api.contazen.ro/v1/clients \
        -H "Authorization: Bearer sk_live_YOUR_API_KEY"
      ```

      ```javascript Node.js theme={null}
      const apiKey = 'sk_live_YOUR_API_KEY';

      const response = await fetch('https://api.contazen.ro/v1/clients', {
        headers: {
          'Authorization': `Bearer ${apiKey}`
        }
      });

      const data = await response.json();
      console.log(data);
      ```

      ```python Python theme={null}
      import requests

      api_key = 'sk_live_YOUR_API_KEY'

      response = requests.get(
          'https://api.contazen.ro/v1/clients',
          headers={'Authorization': f'Bearer {api_key}'}
      )

      print(response.json())
      ```

      ```php PHP theme={null}
      $apiKey = 'sk_live_YOUR_API_KEY';

      $ch = curl_init('https://api.contazen.ro/v1/clients');
      curl_setopt($ch, CURLOPT_HTTPHEADER, [
          'Authorization: Bearer ' . $apiKey
      ]);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

      $response = curl_exec($ch);
      $data = json_decode($response, true);

      print_r($data);
      ```
    </CodeGroup>
  </Step>
</Steps>

## Create your first invoice

Now let's create a complete invoice with a client in one API call:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.contazen.ro/v1/invoices \
    -H "Authorization: Bearer sk_live_YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "client_data": {
        "type": "b2b",
        "name": "Acme Corp SRL",
        "cui": "RO12345678",
        "address": "Str. Exemplu nr. 123",
        "city": "București",
        "email": "contact@acmecorp.ro"
      },
      "items": [{
        "description": "Web Development Services",
        "quantity": 10,
        "price": 100,
        "vat_rate": 21
      }]
    }'
  ```

  ```javascript Node.js theme={null}
  const createInvoice = async () => {
    const response = await fetch('https://api.contazen.ro/v1/invoices', {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${apiKey}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        client_data: {
          type: 'b2b',
          name: 'Acme Corp SRL',
          cui: 'RO12345678',
          address: 'Str. Exemplu nr. 123',
          city: 'București',
          email: 'contact@acmecorp.ro'
        },
        items: [{
          description: 'Web Development Services',
          quantity: 10,
          price: 100,
          vat_rate: 21
        }]
      })
    });
    
    const invoice = await response.json();
    console.log('Invoice created:', invoice.data.number);
    return invoice;
  };
  ```

  ```python Python theme={null}
  import requests

  def create_invoice():
      url = 'https://api.contazen.ro/v1/invoices'
      headers = {
          'Authorization': f'Bearer {api_key}',
          'Content-Type': 'application/json'
      }
      
      data = {
          'client_data': {
              'type': 'b2b',
              'name': 'Acme Corp SRL',
              'cui': 'RO12345678',
              'address': 'Str. Exemplu nr. 123',
              'city': 'București',
              'email': 'contact@acmecorp.ro'
          },
          'items': [{
              'description': 'Web Development Services',
              'quantity': 10,
              'price': 100,
              'vat_rate': 21
          }]
      }
      
      response = requests.post(url, json=data, headers=headers)
      invoice = response.json()
      
      print(f"Invoice created: {invoice['data']['number']}")
      return invoice
  ```

  ```php PHP theme={null}
  function createInvoice($apiKey) {
      $url = 'https://api.contazen.ro/v1/invoices';
      
      $data = [
          'client_data' => [
              'type' => 'b2b',
              'name' => 'Acme Corp SRL',
              'cui' => 'RO12345678',
              'address' => 'Str. Exemplu nr. 123',
              'city' => 'București',
              'email' => 'contact@acmecorp.ro'
          ],
          'items' => [[
              'description' => 'Web Development Services',
              'quantity' => 10,
              'price' => 100,
              'vat_rate' => 21
          ]]
      ];
      
      $ch = curl_init($url);
      curl_setopt($ch, CURLOPT_POST, true);
      curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
      curl_setopt($ch, CURLOPT_HTTPHEADER, [
          'Authorization: Bearer ' . $apiKey,
          'Content-Type: application/json'
      ]);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      
      $response = curl_exec($ch);
      $invoice = json_decode($response, true);
      
      echo "Invoice created: " . $invoice['data']['number'];
      return $invoice;
  }
  ```
</CodeGroup>

## What's next?

<CardGroup cols={2}>
  <Card title="Authentication" icon="lock" href="/authentication">
    Learn about API keys and security best practices
  </Card>

  <Card title="Error Handling" icon="triangle-exclamation" href="/errors">
    Understand how to handle API errors gracefully
  </Card>

  <Card title="Client Management" icon="users" href="/api-reference/endpoints/clients/list">
    Explore the clients API endpoints
  </Card>

  <Card title="Invoice Creation" icon="file-invoice" href="/api-reference/endpoints/invoices/create">
    Deep dive into invoice creation options
  </Card>
</CardGroup>

## Example Response

A successful invoice creation returns:

```json theme={null}
{
  "success": true,
  "data": {
    "id": "inv_1a2b3c4d5e",
    "object": "invoice",
    "number": "CTZ-2024-00001",
    "document_type": "fiscal",
    "date": "2024-01-15",
    "due_date": "2024-02-14",
    "client": {
      "id": "9z8y7x6w5v",
      "name": "Acme Corp SRL",
      "cui": "RO12345678"
    },
    "subtotal": 1000.00,
    "vat_amount": 210.00,
    "total": 1210.00,
    "currency": "RON",
    "status": "draft",
    "created_at": 1705334400
  },
  "meta": {
    "version": "v1",
    "response_time": "45.23ms"
  }
}
```

<Note>
  The invoice is created as a draft by default. You can send it to your client using the [send endpoint](/api-reference/endpoints/invoices/send).
</Note>
