# Create Lambda API

The createLambda is a JSON-RPC endpoint that handles the creation of a new lambda function. It requires a lambda configuration as an input. If the creation is successful, it returns a unique identifier for the lambda required to execute it.

For instructions on how to setup your request headers you can follow [authenticated-requests](https://docs.0xpass.io/appendix/api-request-setup/authenticated-requests "mention") guide

### Request Spec

**HTTP Method**: POST

* [**Headers**](https://docs.0xpass.io/appendix/api-request-setup/authenticated-requests):
  * X-Encrypted-Session: Encrypted JWT signature for authentication.
  * X-Encrypted-Key: A string containing the encrypted key for secure communication.
  * X-Encrypted-User: User Input encrypted using Encryption Key
* **Body**:
  * **data**: JSON - A lambda configuration describing how the lambda works

### Response Spec

* **lambda\_uuid**: String - A UUID that uniquely identifies the lambda and is essential for executing it later.

### Request Example

```http
POST / HTTP/1.1
Host: tiramisu.0xpass.io
Content-Type: application/json
X-Encrypted-Session: eJjdnfdknf...
X-Encrypted-Key: jp6t2GVOvzltN+4VGc21ZKPIbLjEvitE34cFYDvVNrcmF2ukcKMTO8R/F0wbonGZM0NZBg2X94FvirH6Hi2U1zFlXN5srkOdvQL3lVNZ86gbfEtJFPOEAeZkxtTOKOsH4ZXPtUbFOjT2Niblo8njOKibOoAMRKIhtsNTTvRXjHRxnNqVs3QcSe7XbO1DbH/pdRgq+YZN13znlSRsupu4G/h/KBEZr98wXFo8PeDV9F8ZV56F90GqQ3wKzFUBwC9rJihGz0omH+eJA0jB/K7BYt30fhWDnqaLNP2eb1mbIjBCmv6sXqu2jtghr3ejl0YwjP9lCO+aVD7bophfb/IyKg==
X-Encrypted-User: jp6t2GVOvzltN+4VGc21ZKPIbLjEvitE34cFYDvVNrcmF2ukcK
{
    "jsonrpc": "2.0",
    "method": "createLambda",
    "params": {
        "data": {
            "authorization": {
                "type": "none"
            },
            "triggers": [
               { "type": "hook"},
            ],
            "verifications": {
                "count": 1
            },
            "envs": [],
            "max_executions": 0,
            "conditions": [
                {
                    "type": "code",
                    "code": "return true",
                    "output_type": "integer",
                    "substitution": true
                }
            ],
            "actions": {
                "type": "personal_sign",
                "check": "",
                "data": "0x000000",
                "substitution": true
            },
            "postHook": []
        }
    },
    "id": 3
}
```

### Response Example

Success:

```json
{
    "jsonrpc": "2.0",
    "result": "a23ef114-c5fb-41c6-b863-0781a3d10ee5",
    "id": 3
}
```

Error:

```json
{
  "jsonrpc": "2.0",
  "error": {
    "code": 401,
    "message": "Unauthorized: Signature verification failed."
  },
  "id": 1
}
```
