# Models

## The CreateTemplateDto object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"CreateTemplateDto":{"type":"object","properties":{"name":{"type":"string","description":"The name of the template"},"description":{"type":"string","description":"The description of the template"},"version":{"type":"number","description":"The version of the template"},"schema":{"type":"object","description":"The schema of the template"},"aiGenerated":{"type":"boolean","description":"Wheter the template was generated using AI"},"vendorSchemaName":{"type":"string","description":"The vendor schema name"},"vendorSchemaVersion":{"type":"number","description":"The vendor schema version"},"vendorSchema":{"type":"object","description":"The vendor schema"},"dereferencedVendorSchema":{"type":"object","description":"The dereferenced vendor schema with resolved $ref references"},"emailAlias":{"type":"string","description":"The email alias"},"state":{"type":"string","description":"The state of the template","enum":["draft","published"],"default":"published"}},"required":["name","version"]}}}}
```

## The ImportFromLedgerDto object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"ImportFromLedgerDto":{"type":"object","properties":{"schema":{"type":"object","description":"The updated schema from Ledger"},"vendorSchemaName":{"type":"string","description":"The vendor schema name"},"vendor_schema_name":{"type":"string","description":"The vendor schema name (alternative)"},"vendorSchemaVersion":{"type":"number","description":"The vendor schema version"},"vendor_schema_version":{"type":"number","description":"The vendor schema version (alternative)"},"vendorSchema":{"type":"object","description":"The vendor schema"},"vendor_schema":{"type":"object","description":"The vendor schema (alternative snake_case)"},"dereferencedVendorSchema":{"type":"object","description":"The dereferenced vendor schema with resolved $ref references"}}}}}}
```

## The UpdateTemplateDto object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"UpdateTemplateDto":{"type":"object","properties":{"name":{"type":"string","description":"The name of the template"},"description":{"type":"string","description":"The description of the template"},"version":{"type":"number","description":"The version of the template"},"schema":{"type":"object","description":"The schema of the template"},"vendorSchemaName":{"type":"string","description":"The vendor schema name"},"vendorSchemaVersion":{"type":"number","description":"The vendor schema version"},"vendorSchema":{"type":"object","description":"The vendor schema"},"dereferencedVendorSchema":{"type":"object","description":"The dereferenced vendor schema with resolved $ref references"},"emailAlias":{"type":"string","description":"The email alias"},"extractionStrategyId":{"type":"string","description":"The uuid of extraction strategy template uses."},"state":{"type":"string","description":"The state of the template","enum":["draft","published"],"default":"published"},"parsingInstructions":{"type":"object","description":"the parsing instructions for a template"}}}}}}
```

## The FileDto object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"FileDto":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier for the file"},"name":{"type":"string","description":"Name of the file"},"fileName":{"type":"string","description":"Original file name"},"fileType":{"type":"string","description":"Type of the file (e.g., MIME type)"},"fileSize":{"type":"number","description":"Size of the file in bytes"},"url":{"type":"string","description":"Public URL of the file"},"createdAt":{"format":"date-time","type":"string","description":"Timestamp when the file was created"},"updatedAt":{"format":"date-time","type":"string","description":"Timestamp when the file was last updated"}},"required":["id","fileName","fileType","fileSize","url","createdAt","updatedAt"]}}}}
```

## The Event object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"Event":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier for the event"},"submissionId":{"type":"string","description":"Related submission ID","nullable":true},"type":{"type":"string","description":"Type of event","enum":["upload","email","conversion","extraction","export","discard","reference","generate-schema","metadata"]},"state":{"type":"string","description":"Current state of the event","enum":["pending","succeed","fail"]},"createdAt":{"format":"date-time","type":"string","description":"Timestamp when the event was created"},"updatedAt":{"format":"date-time","type":"string","description":"Timestamp when the event was last updated"}},"required":["id","submissionId","type","state","createdAt","updatedAt"]}}}}
```

## The CreateSubmissionDto object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"CreateSubmissionDto":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier for the submission"},"name":{"type":"string","description":"Submission name"},"templateId":{"type":"number","description":"ID of the associated template"},"uploaderUserId":{"type":"string","description":"ID of the user who uploaded the submission"},"userId":{"type":"string","description":"ID of the user associated with the submission"},"emailSender":{"type":"string","description":"Email address of the sender"},"emailBody":{"type":"string","description":"Email body or additional context"},"emailMessageId":{"type":"string","description":"Email message ID"},"payload":{"type":"object","description":"Submission payload data"},"manualPayload":{"type":"object","description":"Manual payload data"},"metaPayload":{"type":"object","description":"Metadata payload"}}}}}}
```

## The Strategy object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"Strategy":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier for the strategy"},"identifier":{"type":"string","description":"Identifier of the strategy type","enum":["extraction-claude-3-7","extraction-gemini-2-5-loose","extraction-claude-3-7-thinking","extraction-atomic"]},"type":{"type":"string","description":"Type of the strategy","default":"extraction"},"displayName":{"type":"string","description":"Display name of the strategy"},"description":{"type":"string","description":"Description of the strategy"},"createdAt":{"format":"date-time","type":"string","description":"Timestamp when the strategy was created"},"updatedAt":{"format":"date-time","type":"string","description":"Timestamp when the strategy was last updated"}},"required":["id","identifier","type","displayName","createdAt","updatedAt"]}}}}
```

## The Template object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"Template":{"type":"object","properties":{"id":{"type":"number","description":"The ID of the template"},"templateId":{"type":"string","description":"The UUID of the template"},"name":{"type":"string","description":"The name of the template"},"description":{"type":"string","description":"The description of the template"},"version":{"type":"number","description":"The version of the template"},"schema":{"type":"object","description":"The schema of the template"},"vendorSchemaName":{"type":"string","description":"The vendor schema name"},"vendorSchemaVersion":{"type":"number","description":"The vendor schema version"},"vendorSchema":{"type":"object","description":"The vendor schema"},"dereferencedVendorSchema":{"type":"object","description":"The dereferenced vendor schema with resolved $ref references"},"aiGenerated":{"type":"boolean","description":"Whether the template was generated using AI"},"emailAlias":{"type":"string","description":"The email alias"},"extractionStrategyId":{"type":"string","description":"The uuid of extraction strategy template uses."},"extractionStrategy":{"description":"Associated extraction strategy","allOf":[{"$ref":"#/components/schemas/Strategy"}]},"referenceStrategy":{"description":"Associated reference strategy","allOf":[{"$ref":"#/components/schemas/Strategy"}]},"state":{"type":"string","description":"The state of the template","enum":["draft","published"],"default":"published"},"parsingInstructions":{"type":"object","description":"the parsing instructions for a template"}},"required":["id","templateId","name","version","aiGenerated","extractionStrategyId","extractionStrategy","referenceStrategy","state","parsingInstructions"]},"Strategy":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier for the strategy"},"identifier":{"type":"string","description":"Identifier of the strategy type","enum":["extraction-claude-3-7","extraction-gemini-2-5-loose","extraction-claude-3-7-thinking","extraction-atomic"]},"type":{"type":"string","description":"Type of the strategy","default":"extraction"},"displayName":{"type":"string","description":"Display name of the strategy"},"description":{"type":"string","description":"Description of the strategy"},"createdAt":{"format":"date-time","type":"string","description":"Timestamp when the strategy was created"},"updatedAt":{"format":"date-time","type":"string","description":"Timestamp when the strategy was last updated"}},"required":["id","identifier","type","displayName","createdAt","updatedAt"]}}}}
```

## The SubmissionStatus object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"SubmissionStatus":{"type":"string","enum":["created","processing","processing-failed","processed","in-review","completed","exported","export-failed","discarded","preparing","queued"]}}}}
```

## The SubmissionDto object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"SubmissionDto":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier for the submission"},"submissionNumber":{"type":"number","description":"Submission sequence number"},"name":{"type":"string","description":"Submission name"},"template":{"description":"Associated template","allOf":[{"$ref":"#/components/schemas/Template"}]},"templateId":{"type":"number","description":"ID of the associated template"},"uploaderUserId":{"type":"string","description":"ID of the user who uploaded the submission"},"userId":{"type":"string","description":"ID of the user associated with the submission"},"files":{"description":"Files attached to the submission","type":"array","items":{"type":"string"}},"status":{"description":"Current status of the submission","allOf":[{"$ref":"#/components/schemas/SubmissionStatus"}]},"emailSender":{"type":"string","description":"Email address of the sender"},"emailBody":{"type":"string","description":"Email body or additional context"},"emailMessageId":{"type":"string","description":"Email message ID"},"payload":{"type":"object","description":"Submission payload data"},"manualPayload":{"type":"object","description":"Manual payload data"},"metaPayload":{"type":"object","description":"Metadata payload"},"OBEExtraction":{"type":"string","description":"ID of the old backend extraction event"},"NBEExtraction":{"type":"string","description":"ID of the new backend extraction event"},"createdAt":{"format":"date-time","type":"string","description":"Timestamp when the submission was created"},"updatedAt":{"format":"date-time","type":"string","description":"Timestamp when the submission was last updated"}},"required":["id","submissionNumber","name","template","templateId","files","status","createdAt","updatedAt"]},"Template":{"type":"object","properties":{"id":{"type":"number","description":"The ID of the template"},"templateId":{"type":"string","description":"The UUID of the template"},"name":{"type":"string","description":"The name of the template"},"description":{"type":"string","description":"The description of the template"},"version":{"type":"number","description":"The version of the template"},"schema":{"type":"object","description":"The schema of the template"},"vendorSchemaName":{"type":"string","description":"The vendor schema name"},"vendorSchemaVersion":{"type":"number","description":"The vendor schema version"},"vendorSchema":{"type":"object","description":"The vendor schema"},"dereferencedVendorSchema":{"type":"object","description":"The dereferenced vendor schema with resolved $ref references"},"aiGenerated":{"type":"boolean","description":"Whether the template was generated using AI"},"emailAlias":{"type":"string","description":"The email alias"},"extractionStrategyId":{"type":"string","description":"The uuid of extraction strategy template uses."},"extractionStrategy":{"description":"Associated extraction strategy","allOf":[{"$ref":"#/components/schemas/Strategy"}]},"referenceStrategy":{"description":"Associated reference strategy","allOf":[{"$ref":"#/components/schemas/Strategy"}]},"state":{"type":"string","description":"The state of the template","enum":["draft","published"],"default":"published"},"parsingInstructions":{"type":"object","description":"the parsing instructions for a template"}},"required":["id","templateId","name","version","aiGenerated","extractionStrategyId","extractionStrategy","referenceStrategy","state","parsingInstructions"]},"Strategy":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier for the strategy"},"identifier":{"type":"string","description":"Identifier of the strategy type","enum":["extraction-claude-3-7","extraction-gemini-2-5-loose","extraction-claude-3-7-thinking","extraction-atomic"]},"type":{"type":"string","description":"Type of the strategy","default":"extraction"},"displayName":{"type":"string","description":"Display name of the strategy"},"description":{"type":"string","description":"Description of the strategy"},"createdAt":{"format":"date-time","type":"string","description":"Timestamp when the strategy was created"},"updatedAt":{"format":"date-time","type":"string","description":"Timestamp when the strategy was last updated"}},"required":["id","identifier","type","displayName","createdAt","updatedAt"]},"SubmissionStatus":{"type":"string","enum":["created","processing","processing-failed","processed","in-review","completed","exported","export-failed","discarded","preparing","queued"]}}}}
```

## The UploadRequestDto object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"UploadRequestDto":{"type":"object","properties":{"fileName":{"type":"string","description":"Name of the file to upload"},"contentType":{"type":"string","description":"MIME type of the file"}},"required":["fileName","contentType"]}}}}
```

## The UpdateSubmissionDto object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"UpdateSubmissionDto":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier for the submission"},"submissionNumber":{"type":"number","description":"Submission sequence number"},"name":{"type":"string","description":"Submission name"},"templateId":{"type":"number","description":"ID of the associated template"},"uploaderUserId":{"type":"string","description":"ID of the user who uploaded the submission"},"userId":{"type":"string","description":"ID of the user associated with the submission"},"status":{"description":"Current status of the submission","allOf":[{"$ref":"#/components/schemas/SubmissionStatus"}]},"emailSender":{"type":"string","description":"Email address of the sender"},"emailBody":{"type":"string","description":"Email body or additional context"},"emailMessageId":{"type":"string","description":"Email message ID"},"payload":{"type":"object","description":"Submission payload data"},"manualPayload":{"type":"object","description":"Manual payload data"},"metaPayload":{"type":"object","description":"Metadata payload"},"createdAt":{"format":"date-time","type":"string","description":"Timestamp when the submission was created"},"updatedAt":{"format":"date-time","type":"string","description":"Timestamp when the submission was last updated"}}},"SubmissionStatus":{"type":"string","enum":["created","processing","processing-failed","processed","in-review","completed","exported","export-failed","discarded","preparing","queued"]}}}}
```

## The WebhookEventInfoDto object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"WebhookEventInfoDto":{"type":"object","properties":{"eventType":{"type":"string","description":"Event type identifier"},"description":{"type":"string","description":"Human-readable description of when this event is triggered"},"examplePayload":{"type":"object","description":"Example payload structure for this event type"}},"required":["eventType","description","examplePayload"]}}}}
```

## The WebhookEventType object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"WebhookEventType":{"type":"string","enum":["extracted","export","validation-success"]}}}}
```

## The WebhookSubscriberCreateDto object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"WebhookSubscriberCreateDto":{"type":"object","properties":{"event":{"description":"Event type that triggers the webhook","allOf":[{"$ref":"#/components/schemas/WebhookEventType"}]},"url":{"type":"string","description":"URL where webhook notifications will be sent"}},"required":["event","url"]},"WebhookEventType":{"type":"string","enum":["extracted","export","validation-success"]}}}}
```

## The WebhookSubscriber object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"WebhookSubscriber":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of the webhook subscriber"},"event":{"description":"Event type that triggers the webhook","allOf":[{"$ref":"#/components/schemas/WebhookEventType"}]},"url":{"type":"string","description":"URL where webhook notifications will be sent"},"secret":{"type":"object","description":"Secret token used for HMAC signature generation"},"createdAt":{"format":"date-time","type":"string","description":"Timestamp when the webhook subscription was created"},"updatedAt":{"format":"date-time","type":"string","description":"Timestamp when the webhook subscription was last updated"}},"required":["id","event","url","secret","createdAt","updatedAt"]},"WebhookEventType":{"type":"string","enum":["extracted","export","validation-success"]}}}}
```

## The WebhookSubscriberUpdateDto object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"WebhookSubscriberUpdateDto":{"type":"object","properties":{"event":{"description":"Event type that triggers the webhook","allOf":[{"$ref":"#/components/schemas/WebhookEventType"}]},"url":{"type":"string","description":"URL where webhook notifications will be sent"}}},"WebhookEventType":{"type":"string","enum":["extracted","export","validation-success"]}}}}
```

## The WebhookSubscriberDeleteResponseDto object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"WebhookSubscriberDeleteResponseDto":{"type":"object","properties":{"success":{"type":"boolean","description":"Indicates if the delete operation was successful"}},"required":["success"]}}}}
```

## The UserDto object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"UserDto":{"type":"object","properties":{"id":{"type":"string","description":"Clerk user ID"},"firstName":{"type":"string","description":"User first name","nullable":true},"lastName":{"type":"string","description":"User last name","nullable":true},"imageUrl":{"type":"string","description":"User profile image URL","nullable":true}},"required":["id"]}}}}
```

## The SubmissionEntryDTO object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"SubmissionEntryDTO":{"type":"object","properties":{"submissionId":{"type":"string","description":"The ID of the submission"},"generateTemplate":{"type":"boolean","description":"Whether to generate a template for the submission","default":false}},"required":["submissionId"]}}}}
```

## The SubmissionResponseDto object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"SubmissionResponseDto":{"type":"object","properties":{"submissionId":{"type":"string","description":"The ID of the submission"},"message":{"type":"string","description":"Response message"},"templateId":{"type":"number","description":"The ID of the template if generated"}},"required":["submissionId","message"]}}}}
```

## The CreateApiClientsRequestDto object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"CreateApiClientsRequestDto":{"type":"object","properties":{}}}}}
```

## The CreateApiClientsResponseDto object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"CreateApiClientsResponseDto":{"type":"object","properties":{"clientSecret":{"type":"string","description":"The raw client secret (only shown once during creation)"},"message":{"type":"string","description":"Important message about storing the secret"}},"required":["clientSecret","message"]}}}}
```

## The ApiClient object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"ApiClient":{"type":"object","properties":{}}}}}
```

## The ListApiClientsResponseDto object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"ListApiClientsResponseDto":{"type":"object","properties":{"clients":{"type":"array","items":{"$ref":"#/components/schemas/ApiClient"}}},"required":["clients"]},"ApiClient":{"type":"object","properties":{}}}}}
```

## The RevokeApiClientResponseDto object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"RevokeApiClientResponseDto":{"type":"object","properties":{"message":{"type":"string"}},"required":["message"]}}}}
```

## The RotateSecretResponseDto object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"RotateSecretResponseDto":{"type":"object","properties":{"clientId":{"type":"string"},"clientSecret":{"type":"string"},"message":{"type":"string"}},"required":["clientId","clientSecret","message"]}}}}
```

## The ApiClientsRequestDto object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"ApiClientsRequestDto":{"type":"object","properties":{"clientId":{"type":"string","description":"The API client ID provided when the API client was created"},"clientSecret":{"type":"string","description":"The API client secret provided when the API client was created"},"organizationId":{"type":"string","description":"The organization ID associated with this API client"}},"required":["clientId","clientSecret","organizationId"]}}}}
```

## The GetTokenResponseDto object

```json
{"openapi":"3.0.0","info":{"title":"Formflow API","version":"1.0"},"components":{"schemas":{"GetTokenResponseDto":{"type":"object","properties":{"token":{"type":"string","description":"JWT access token to use for authenticated API requests"},"token_type":{"type":"string","description":"Type of token (always \"Bearer\")"},"expires_in":{"type":"number","description":"Token expiration time in seconds"}},"required":["token","token_type","expires_in"]}}}}
```
