# Create a new builder session A builder session is required to start drafting a document with the Embeddable Builder (EB). Each session is isolated and contains all document-related data. Once the session ends, all data is deleted from our servers. To create a session, you need: - A template ID - Get this from our Template Listing API or let the end-user pick one via the hosted Template Browser UI. - A list of languages - The languages must match the languages available for the selected template. The language determines the final document's language that the end-user drafts. Currently, only one language can be provided. - A document name - Acts like a file name. It's shown in the builder UI and can be edited by the end-user. Participant details You can provide end-user details, such as display name and email, for your reference. These will be required later for collaboration features like commenting, but they are not currently in use. You can use the External ID field to store your internal user ID, which you can later use to match our participants with your users if needed. Redirect URL After creating a session, you'll get a one-time URL to send the end-user to our hosted builder UI. Opening the link creates a secure session with access to that document only. The redirect URL is valid for 15 minutes. #### Handlers You need to provide handlers that redirect the end user back to your service after drafting. Success handler The user is redirected to this URL after completing the drafting session and filling in all the required information. The document is then considered "ready" and cannot be altered. Please note that the endpoint may be called multiple times if users navigates back to our builder via browser history. Cancel handler The user is redirected to this URL after canceling the drafting session. The builder session remains intact. If the user navigates back to our UI using browser history, they can resume drafting. Therefore, it is possible for this handler to be called multiple times. Delete handler The user is redirected to this URL after the document is deleted. Document can be deleted via API and end-users can delete the document through the UI. Once deleted, the document cannot be altered, but it remains accessible via the API for a certain period before being permanently deleted. If the user navigates back to the builder after deletion, they will be automatically redirected to this handler. Consequently, this endpoint may be called multiple times. Error handler The user is redirected to this URL when an unexpected error occurs. #### Handler url parameters Handler URLs are appended (existing parameters will remain unchanged) with the following query parameters: | Parameter | Description | | --------------- | ---------------------------------------------------- | | session_id | Builder session ID | | participant_id| Builder participant ID | Endpoint: POST /api/builder/sessions Version: 0.1.0 Security: APIKey ## Header parameters: - `Accept` (string, required) Specify the response format. Enum: "application/json" ## Request fields (application/json): - `contract` (object, required) - `contract.document_name` (string, required) - `contract.languages` (array, required) - `contract.template_id` (string, required) - `handlers` (object, required) - `handlers.cancel_handler` (object, required) - `handlers.cancel_handler.method` (string, required) - `handlers.cancel_handler.url` (string, required) - `handlers.delete_handler` (object, required) - `handlers.error_handler` (object, required) - `handlers.success_handler` (object, required) - `participant` (object) - `participant.display_name` (string) - `participant.email` (string) - `participant.external_id` (string) - `ui_language` (string) Enum: "en-GB", "fi", "de", "pl", "sv" ## Response 201 fields (application/json): - `data` (object) - `data.id` (string, required) - `data.participant` (object, required) - `data.participant.display_name` (string,null, required) - `data.participant.email` (string,null, required) - `data.participant.external_id` (string,null, required) - `data.participant._data_type` (string,null) - `data.participant.token` (string) - `data.url` (string, required)