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

# Projects

> Create, update, and manage your script projects.

# Project Management

Projects are the core unit on Leaf7. Each project represents a single script or script hub with its own source code, keys, settings, and analytics.

***

## Create a project

<Note>
  Every project gets a unique `project_id` (UUID) on creation. This ID is used across all endpoints.
</Note>

`POST` `/api/vendor/projects`

#### Headers

| Name            | Type   | Required | Description           |
| --------------- | ------ | -------- | --------------------- |
| `Authorization` | String | ✅        | `Bearer YOUR_API_KEY` |

#### Request Body

| Name             | Type    | Required | Description                                                   |
| ---------------- | ------- | -------- | ------------------------------------------------------------- |
| `name`           | String  | ✅        | Display name of your project (max 100 chars)                  |
| `description`    | String  | ❌        | Short description (max 255 chars)                             |
| `ffa_active`     | Boolean | ❌        | Enable Free-For-All mode (no key required). Default: `false`  |
| `webhook_url`    | String  | ❌        | Discord webhook URL for execution notifications               |
| `notify_enabled` | Boolean | ❌        | Toggle webhook notifications. Default: `true`                 |
| `silent_mode`    | Boolean | ❌        | Suppress debug output in the Roblox console. Default: `false` |

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://auth.leaf7.fun/api/vendor/projects/ \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Premium Hub",
      "description": "My premium script hub",
      "ffa_active": false,
      "webhook_url": "https://discord.com/api/webhooks/...",
      "notify_enabled": true,
      "silent_mode": false
    }'
  ```

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

  resp = requests.post(
      "https://auth.leaf7.fun/api/vendor/projects/",
      headers={"Authorization": "Bearer YOUR_API_KEY"},
      json={
          "name": "Premium Hub",
          "description": "My premium script hub",
          "ffa_active": False,
          "notify_enabled": True
      }
  )
  print(resp.json())
  ```
</CodeGroup>

<Tabs>
  <Tab title="201 Created">
    ```json theme={null}
    {
        "project_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
        "name": "Premium Hub",
        "description": "My premium script hub",
        "ffa_active": false,
        "is_active": true,
        "webhook_url": "https://discord.com/api/webhooks/...",
        "notify_enabled": true,
        "silent_mode": false,
        "encrypted_source": null,
        "version": "0.0.0"
    }
    ```
  </Tab>

  <Tab title="401 Unauthorized">
    ```json theme={null}
    { "detail": "Not authenticated" }
    ```
  </Tab>
</Tabs>

***

## Get all projects

`GET` `/api/vendor/projects`

Returns all projects owned by the authenticated vendor.

#### Headers

| Name            | Type   | Required | Description           |
| --------------- | ------ | -------- | --------------------- |
| `Authorization` | String | ✅        | `Bearer YOUR_API_KEY` |

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET https://auth.leaf7.fun/api/vendor/projects/ \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

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

  resp = requests.get(
      "https://auth.leaf7.fun/api/vendor/projects/",
      headers={"Authorization": "Bearer YOUR_API_KEY"}
  )
  print(resp.json())
  ```
</CodeGroup>

<Tabs>
  <Tab title="200 OK">
    ```json theme={null}
    [
        {
            "project_id": "a1b2c3d4-...",
            "name": "Premium Hub",
            "description": "My premium script hub",
            "ffa_active": false,
            "is_active": true,
            "webhook_url": null,
            "notify_enabled": true,
            "silent_mode": false,
            "encrypted_source": "print('Hello World')",
            "version": "0.0.3"
        }
    ]
    ```

    <Note>
      The `encrypted_source` field in the response contains the **decrypted raw source code** for display purposes. It is stored encrypted at rest on the server.
    </Note>
  </Tab>
</Tabs>

***

## Get a single project

`GET` `/api/vendor/projects/{project_id}`

#### Path Parameters

| Name         | Type   | Required | Description         |
| ------------ | ------ | -------- | ------------------- |
| `project_id` | String | ✅        | UUID of the project |

<Tabs>
  <Tab title="200 OK">
    ```json theme={null}
    {
        "project_id": "a1b2c3d4-...",
        "name": "Premium Hub",
        "ffa_active": false,
        "is_active": true,
        "encrypted_source": "print('Hello World')",
        "version": "0.0.3"
    }
    ```
  </Tab>

  <Tab title="404 Not Found">
    ```json theme={null}
    { "detail": "Project not found" }
    ```
  </Tab>
</Tabs>

***

## Update a project

`PUT` `/api/vendor/projects/{project_id}`

Update any project property. Only include fields you want to change — unspecified fields remain unchanged.

#### Path Parameters

| Name         | Type   | Required | Description         |
| ------------ | ------ | -------- | ------------------- |
| `project_id` | String | ✅        | UUID of the project |

#### Request Body

| Name                  | Type    | Required | Description                                 |
| --------------------- | ------- | -------- | ------------------------------------------- |
| `name`                | String  | ❌        | New project name                            |
| `description`         | String  | ❌        | New description                             |
| `ffa_active`          | Boolean | ❌        | Toggle FFA mode                             |
| `encrypted_source`    | String  | ❌        | Raw Lua source code to upload               |
| `webhook_url`         | String  | ❌        | Discord webhook URL                         |
| `notify_enabled`      | Boolean | ❌        | Toggle notifications                        |
| `silent_mode`         | Boolean | ❌        | Toggle silent mode                          |
| `hwid_reset_cooldown` | Integer | ❌        | Hours between allowed HWID resets (via bot) |
| `discord_role_id`     | String  | ❌        | Discord role ID to assign to buyers         |
| `version`             | String  | ❌        | Manual version override (e.g. `"1.2.0"`)    |

<Warning>
  When you upload new source code via `encrypted_source`, the version **auto-increments** the patch number unless you explicitly set `version` in the same request.
</Warning>

<Info>
  **L7\_SEND\_WEBHOOK macros** in your source code are automatically preprocessed on upload. The webhook URLs and templates are extracted and stored securely — they never reach the client.
</Info>

<CodeGroup>
  ```bash cURL — Upload source theme={null}
  curl -X PUT https://auth.leaf7.fun/api/vendor/projects/PROJECT_ID/ \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "encrypted_source": "print(\"Hello from Leaf7!\")\nprint(L7_LinkedDiscordID)"
    }'
  ```

  ```bash cURL — Toggle FFA theme={null}
  curl -X PUT https://auth.leaf7.fun/api/vendor/projects/PROJECT_ID/ \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{ "ffa_active": true }'
  ```
</CodeGroup>

<Tabs>
  <Tab title="200 OK">
    ```json theme={null}
    {
        "project_id": "a1b2c3d4-...",
        "name": "Premium Hub",
        "version": "0.0.4",
        "encrypted_source": "print(\"Hello from Leaf7!\")..."
    }
    ```
  </Tab>

  <Tab title="400 Macro Error">
    ```json theme={null}
    { "detail": "Macro error: Invalid webhook URL in L7_SEND_WEBHOOK" }
    ```
  </Tab>
</Tabs>

***

## Delete a project

`DELETE` `/api/vendor/projects/{project_id}`

<Warning>
  This action is **irreversible**. All associated keys, buyer keys, and webhook templates will be permanently deleted.
</Warning>

#### Path Parameters

| Name         | Type   | Required | Description                   |
| ------------ | ------ | -------- | ----------------------------- |
| `project_id` | String | ✅        | UUID of the project to delete |

<Tabs>
  <Tab title="204 No Content">
    *(Empty response — project deleted successfully)*
  </Tab>

  <Tab title="404 Not Found">
    ```json theme={null}
    { "detail": "Project not found" }
    ```
  </Tab>
</Tabs>
