# How to Set Up Signed Embed

## How to Set Up

### Prepare signed embed

* Prepare API Key and Secret
  * Open `Workspace settings` and click menu `API Keys`.
  * Click the `Add API Key` button and create new API Key.
  * Make a note of the API Key and API Secret (they will be used later for API calls).
* Open the notebook
  * Open the notebook you want to share.
  * Click the `Share` button in the header and select `Signed Embed` tab.
* Publish signed embed
  * Choose the pages you want to publish.
  * Set the options for publishing.
  * Click the `Publish` button.
* Configure signed embed settings.
  * Add API Key to use in `Permitted API Keys` section.
  * If you want to set parameter values when issuing a token, configure them in the `Server-side parameters` section.

### Issue token from server

* Use the following API to issue a token
  * The required arguments for calling the API can be found on the `Setup guide` tab.
  * Perform the API call on the server side to prevent the **API Secret** from being exposed externally.
  * Issue a token for each user session, and do not reuse it (it expires after 1 hour by default).

{% openapi src="<https://api.codatum.com/api/notebook/spec.json>" path="/api/notebook/issueToken" method="post" %}
<https://api.codatum.com/api/notebook/spec.json>
{% endopenapi %}

### Embed in frontend

* Use [Codatum Embed SDK](https://github.com/codatum/codatum-embed-js) to embed in your frontend
  * The `embedUrl` required for embedding can be found on the `Setup guide` tab
  * Set `tokenProvider` to the API that issues tokens on the server side
  * For all other configurable options, see the [SDK README](https://github.com/codatum/codatum-embed-js/tree/main/packages/embed#readme)

## Appendix

### Frequently Asked Questions

#### Getting "Missing param: xxx" error when issuing a token

* To issue a token, all server-side parameters must be included in the request
* This error occurs when a parameter with the ID "xxx" is not included in the request

#### Getting "The following parameters must be set by the server" error when sending client-side parameters

* You are trying to change server-side parameters when sending client-side parameters
* To change server-side parameters, a new token must be issued

#### Parameters not updating when sending client-side parameters

* Check that the parameter you are sending is not specified as a server-side parameter
* Verify that `param_value` is in the correct JSON string format
* Confirm that `param_id` matches an existing parameter ID
