> ## 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.

# Rust SDK forms client

> Submit Paubox Form responses, with file attachments, using the Rust SDK.

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

## Creating a client

**Standalone** (creates its own HTTP connection pool):

```rust theme={null}
use paubox::forms::FormsClient;

let client = FormsClient::new();
```

**Shared connection pool** (reuses the HTTP client from an existing `PauboxClient`):

```rust theme={null}
let forms = email_client.forms();
```

## Submit a form

Build a `FormSubmission` and call `submit_form`:

```rust theme={null}
use paubox::forms::FormSubmission;
use serde_json::json;

let submission = FormSubmission::builder()
    .form_data(json!({
        "first_name": "Jane",
        "last_name":  "Smith",
        "email":      "jane@example.com"
    }))
    .build()?;

client.submit_form("your-form-uuid", &submission).await?;
```

`submit_form` returns `Ok(())` on success (HTTP 201).

### Submitting with file attachments

The maximum total request size is 250 MB. `FormAttachment::from_bytes` base64-encodes automatically:

```rust theme={null}
use paubox::forms::{FormAttachment, FormSubmission};
use std::fs;

let data = fs::read("consent.pdf")?;
let attachment = FormAttachment::from_bytes("consent.pdf", &data);

let submission = FormSubmission::builder()
    .form_data(json!({ "first_name": "Jane" }))
    .attachment(attachment)
    .build()?;

client.submit_form("your-form-uuid", &submission).await?;
```

If you already have base64-encoded content:

```rust theme={null}
let attachment = FormAttachment::from_base64("consent.pdf", encoded_string);
```

## Error handling

```rust theme={null}
use paubox::PauboxError;

match client.submit_form("your-form-uuid", &submission).await {
    Ok(()) => println!("Submitted"),
    Err(PauboxError::Http { status, body }) => {
        eprintln!("HTTP {}: {}", status, body);
    }
    Err(e) => eprintln!("Error: {}", e),
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.