SDK Reference: HTTP Trigger
The HTTP Trigger fires when an HTTP request is made to the workflow's designated endpoint. This allows you to start workflows from external systems.
http.Trigger
Creates the HTTP trigger instance.
import "github.com/smartcontractkit/cre-sdk-go/capabilities/networking/http"
httpTrigger := http.Trigger(&http.Config{
AuthorizedKeys: []*http.AuthorizedKey{
{
Type: http.KeyType_KEY_TYPE_ECDSA_EVM,
PublicKey: "0x...",
},
},
})
http.Config
The configuration struct for the HTTP trigger.
Field | Type | Description |
|---|---|---|
AuthorizedKeys | []*AuthorizedKey | Required for deployed workflows. A slice of EVM addresses authorized to trigger the workflow via HTTP. |
http.AuthorizedKey
Defines an EVM address authorized to trigger the workflow.
Field | Type | Description |
|---|---|---|
Type | KeyType | The type of the key. Must be http.KeyType_KEY_TYPE_ECDSA_EVM (currently the only supported authentication method). |
PublicKey | string | An EVM address (e.g., "0xb08E004bd2b5aFf1F5F950d141f449B1c05800eb") authorized to trigger this workflow. |
http.Payload
The payload passed to the callback function.
| Field | Type | Description |
|---|---|---|
Input | []byte | The JSON input from the HTTP request body as raw bytes. |
Key | *AuthorizedKey | The EVM address that signed the request (matches one of the AuthorizedKeys). |
Callback Function
Your callback function for HTTP triggers must conform to this signature:
import "github.com/smartcontractkit/cre-sdk-go/capabilities/networking/http"
func onHttpTrigger(config *Config, runtime cre.Runtime, payload *http.Payload) (*YourReturnType, error)
Parameters:
config: Your workflow's static configuration struct.runtime: The runtime object used to invoke capabilities.payload: The HTTP payload containing the request input and signing key.