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

# Forms client

> Retrieve Paubox Form schemas and submit form responses using the C# SDK.

The Forms client does not require API credentials. Forms are identified by a UUID that you obtain from the Paubox dashboard.

## Instantiation

```csharp theme={null}
var formsLib = new FormsLibrary();
```

Use `IFormsLibrary` for dependency injection in ASP.NET Core:

```csharp theme={null}
builder.Services.AddSingleton<IFormsLibrary, FormsLibrary>();
```

## Get a form

Retrieve a form's metadata, field schema, and rendered HTML/CSS:

```csharp theme={null}
Form form = formsLib.GetForm("your-form-uuid");

Console.WriteLine("Title: " + form.Title);
Console.WriteLine("HTML: "  + form.FormHtml);
```

The `Form` object includes:

| Property                  | Description                               |
| ------------------------- | ----------------------------------------- |
| `Title`                   | Display name of the form                  |
| `FormJson`                | Parsed field schema                       |
| `FormHtml`                | Rendered HTML for embedding               |
| `FormCss`                 | Associated stylesheet                     |
| `Active`                  | Whether the form is accepting submissions |
| `SubmissionCount`         | Number of submissions received            |
| `CreatedAt` / `UpdatedAt` | Timestamps                                |

## Submit a form

```csharp theme={null}
var formData = new Dictionary<string, object>
{
    { "first_name", "Jane" },
    { "last_name",  "Smith" },
    { "email",      "jane@example.com" }
};

formsLib.SubmitForm("your-form-uuid", formData);
```

`SubmitForm` returns `void` on success and throws on failure.

### Submitting with file attachments

The maximum total request size is 250 MB.

```csharp theme={null}
byte[] fileBytes = File.ReadAllBytes("consent.pdf");

var attachments = new[]
{
    new FormAttachment
    {
        Name    = "consent.pdf",
        Content = Convert.ToBase64String(fileBytes)
    }
};

formsLib.SubmitForm("your-form-uuid", formData, attachments);
```

The `FormAttachment` properties:

| Property  | Description                   |
| --------- | ----------------------------- |
| `Name`    | File name including extension |
| `Content` | Base64-encoded file content   |

## Error handling

```csharp theme={null}
try
{
    Form form = formsLib.GetForm("your-form-uuid");
    formsLib.SubmitForm("your-form-uuid", formData);
}
catch (ArgumentException ex)
{
    // Null or empty formId / formData
    Console.WriteLine("Invalid argument: " + ex.Message);
}
catch (SystemException ex)
{
    // API error (404 form not found, 400 bad request, etc.)
    Console.WriteLine("API error: " + ex.Message);
}
```
