From 14038716e3261f331a1baa687cb9a04865cfaeaf Mon Sep 17 00:00:00 2001 From: Gayathri Vijayan <66356931+grvijayan@users.noreply.github.com> Date: Tue, 4 Nov 2025 16:18:30 +0100 Subject: [PATCH] fix(doc): update actions v2 examples (#11017) # Which Problems Are Solved This PR fixes the examples used in the actions v2 docs. # How the Problems Are Solved * By fixing the actions v2 import path used in the example # Additional Changes * Use actions v2 instead of actions v2beta in the examples * Use v2 `CreateUser` instead of v2beta `AddHumanUser` in `request-manipulation` example # Additional Context - Follow up for https://github.com/zitadel/zitadel-go/issues/523 --- .../guides/integrate/actions/testing-event.md | 4 +- .../actions/testing-function-manipulation.md | 4 +- .../integrate/actions/testing-function.md | 4 +- .../actions/testing-request-manipulation.md | 43 ++++--- .../actions/testing-request-signature.md | 106 ++++++++++-------- .../integrate/actions/testing-request.md | 88 ++++++++------- .../actions/testing-response-manipulation.md | 4 +- .../integrate/actions/testing-response.md | 20 ++-- .../integrate/actions/webhook-site-setup.md | 4 +- 9 files changed, 152 insertions(+), 125 deletions(-) diff --git a/docs/docs/guides/integrate/actions/testing-event.md b/docs/docs/guides/integrate/actions/testing-event.md index fe1e872dd..c2325dbb2 100644 --- a/docs/docs/guides/integrate/actions/testing-event.md +++ b/docs/docs/guides/integrate/actions/testing-event.md @@ -74,7 +74,7 @@ target can be created as follows: See [Create a target](/apis/resources/action_service_v2/action-service-create-target) for more detailed information. ```shell -curl -L -X POST 'https://$CUSTOM-DOMAIN/v2beta/actions/targets' \ +curl -L -X POST 'https://$CUSTOM-DOMAIN/v2/actions/targets' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ @@ -98,7 +98,7 @@ condition. See [Set an execution](/apis/resources/action_service_v2/action-service-set-execution) for more detailed information. ```shell -curl -L -X PUT 'https://$CUSTOM-DOMAIN/v2beta/actions/executions' \ +curl -L -X PUT 'https://$CUSTOM-DOMAIN/v2/actions/executions' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ diff --git a/docs/docs/guides/integrate/actions/testing-function-manipulation.md b/docs/docs/guides/integrate/actions/testing-function-manipulation.md index d95169be3..10d3b71ab 100644 --- a/docs/docs/guides/integrate/actions/testing-function-manipulation.md +++ b/docs/docs/guides/integrate/actions/testing-function-manipulation.md @@ -100,7 +100,7 @@ As you see in the example above the target is created with HTTP and port '8090' See [Create a target](/apis/resources/action_service_v2/action-service-create-target) for more detailed information. ```shell -curl -L -X POST 'https://$CUSTOM-DOMAIN/v2beta/actions/targets' \ +curl -L -X POST 'https://$CUSTOM-DOMAIN/v2/actions/targets' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ @@ -124,7 +124,7 @@ condition. See [Set an execution](/apis/resources/action_service_v2/action-service-set-execution) for more detailed information. ```shell -curl -L -X PUT 'https://$CUSTOM-DOMAIN/v2beta/actions/executions' \ +curl -L -X PUT 'https://$CUSTOM-DOMAIN/v2/actions/executions' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ diff --git a/docs/docs/guides/integrate/actions/testing-function.md b/docs/docs/guides/integrate/actions/testing-function.md index c75963247..4e1f6d64d 100644 --- a/docs/docs/guides/integrate/actions/testing-function.md +++ b/docs/docs/guides/integrate/actions/testing-function.md @@ -78,7 +78,7 @@ As you see in the example above the target is created with HTTP and port '8090' See [Create a target](/apis/resources/action_service_v2/action-service-create-target) for more detailed information. ```shell -curl -L -X POST 'https://$CUSTOM-DOMAIN/v2beta/actions/targets' \ +curl -L -X POST 'https://$CUSTOM-DOMAIN/v2/actions/targets' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ @@ -102,7 +102,7 @@ condition. See [Set an execution](/apis/resources/action_service_v2/action-service-set-execution) for more detailed information. ```shell -curl -L -X PUT 'https://$CUSTOM-DOMAIN/v2beta/actions/executions' \ +curl -L -X PUT 'https://$CUSTOM-DOMAIN/v2/actions/executions' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ diff --git a/docs/docs/guides/integrate/actions/testing-request-manipulation.md b/docs/docs/guides/integrate/actions/testing-request-manipulation.md index 9275532d0..de00d5244 100644 --- a/docs/docs/guides/integrate/actions/testing-request-manipulation.md +++ b/docs/docs/guides/integrate/actions/testing-request-manipulation.md @@ -46,15 +46,15 @@ import ( ) type contextRequest struct { - Request *addHumanUserRequestWrapper `json:"request"` + Request *createUserRequestWrapper `json:"request"` } -// addHumanUserRequestWrapper necessary to marshal and unmarshal the JSON into the proto message correctly -type addHumanUserRequestWrapper struct { - user.AddHumanUserRequest +// createUserRequestWrapper necessary to marshal and unmarshal the JSON into the proto message correctly +type createUserRequestWrapper struct { + user.CreateUserRequest } -func (r *addHumanUserRequestWrapper) MarshalJSON() ([]byte, error) { +func (r *createUserRequestWrapper) MarshalJSON() ([]byte, error) { data, err := protojson.Marshal(r) if err != nil { return nil, err @@ -62,7 +62,7 @@ func (r *addHumanUserRequestWrapper) MarshalJSON() ([]byte, error) { return data, nil } -func (r *addHumanUserRequestWrapper) UnmarshalJSON(data []byte) error { +func (r *createUserRequestWrapper) UnmarshalJSON(data []byte) error { return protojson.Unmarshal(data, r) } @@ -82,14 +82,17 @@ func call(w http.ResponseWriter, req *http.Request) { if err := json.Unmarshal(sentBody, request); err != nil { http.Error(w, "error", http.StatusInternalServerError) } - + // build the response from the received request response := request.Request // manipulate the request to send back as response - if response.Metadata == nil { - response.Metadata = make([]*user.SetMetadataEntry, 0) + metadata := response.GetHuman().GetMetadata() + if metadata == nil { + metadata = make([]*user.Metadata, 0) } - response.Metadata = append(response.Metadata, &user.SetMetadataEntry{Key: "organization", Value: []byte("company")}) + metadata = append(metadata, &user.Metadata{Key: "organization", Value: []byte("dunder mifflin")}) + + response.GetHuman().Metadata = metadata // marshal the request into json data, err := json.Marshal(response) @@ -126,7 +129,7 @@ As you see in the example above the target is created with HTTP and port '8090' See [Create a target](/apis/resources/action_service_v2/action-service-create-target) for more detailed information. ```shell -curl -L -X POST 'https://$CUSTOM-DOMAIN/v2beta/actions/targets' \ +curl -L -X POST 'https://$CUSTOM-DOMAIN/v2/actions/targets' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ @@ -149,7 +152,7 @@ To call the target just created before, with the intention to manipulate the req See [Set an execution](/apis/resources/action_service_v2/action-service-set-execution) for more detailed information. ```shell -curl -L -X PUT 'https://$CUSTOM-DOMAIN/v2beta/actions/executions' \ +curl -L -X PUT 'https://$CUSTOM-DOMAIN/v2/actions/executions' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ @@ -176,7 +179,7 @@ curl -L -X POST 'https://$CUSTOM-DOMAIN/v2/users/new' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ --data-raw '{ - "organizationId": "336392597046099971", + "organizationId": "344648897353810062", "human": { "profile": @@ -205,7 +208,7 @@ curl -L -X PUT 'https://$CUSTOM-DOMAIN/v2/users/new' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ --data-raw '{ - "organizationId": "336392597046099971", + "organizationId": "344648897353810062", "human": { "profile": @@ -220,11 +223,15 @@ curl -L -X PUT 'https://$CUSTOM-DOMAIN/v2/users/new' \ "email": { "email": "mini@mouse.com" - } + }, + "metadata": + [ + { + "key": "organization", + "value": "ZHVuZGVyIG1pZmZsaW4=" + } + ] } - "metadata": [ - {"key": "organization", "value": "Y29tcGFueQ=="} - ] }' ``` diff --git a/docs/docs/guides/integrate/actions/testing-request-signature.md b/docs/docs/guides/integrate/actions/testing-request-signature.md index 91028bcb8..fe9913b76 100644 --- a/docs/docs/guides/integrate/actions/testing-request-signature.md +++ b/docs/docs/guides/integrate/actions/testing-request-signature.md @@ -38,10 +38,10 @@ import ( "io" "net/http" - "github.com/zitadel/zitadel/pkg/actions" + "github.com/zitadel/zitadel-go/v3/pkg/actions" ) -const signingKey = "somekey" +const signingKey = "somekey" // signing key received after creating the target // webhook HandleFunc to read the request body and then print out the contents func webhook(w http.ResponseWriter, req *http.Request) { @@ -54,7 +54,7 @@ func webhook(w http.ResponseWriter, req *http.Request) { } defer req.Body.Close() // validate signature - if err := actions.ValidatePayload(sentBody, req.Header.Get(actions.SigningHeader), signingKey); err != nil { + if err := actions.ValidateRequestPayload(sentBody, &req.Header, signingKey); err != nil { // if the signed content is not equal the sent content return an error http.Error(w, "error", http.StatusInternalServerError) return @@ -85,7 +85,7 @@ As you see in the example above the target is created with HTTP and port '8090' See [Create a target](/apis/resources/action_service_v2/action-service-create-target) for more detailed information. ```shell -curl -L -X POST 'https://$CUSTOM-DOMAIN/v2beta/actions/targets' \ +curl -L -X POST 'https://$CUSTOM-DOMAIN/v2/actions/targets' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ @@ -99,7 +99,15 @@ curl -L -X POST 'https://$CUSTOM-DOMAIN/v2beta/actions/targets' \ }' ``` -Save the returned ID to set in the execution. +Example response after creating the target: +```json +{ + "id": "344649040681500814", + "creationDate": "2025-10-31T15:00:36.432595dZ", + "signingKey": "somekey" +} +``` +Save the returned ID to set in the execution. Use the `signingKey` to validate the request signature. ## Set execution @@ -109,7 +117,7 @@ condition. See [Set an execution](/apis/resources/action_service_v2/action-service-set-execution) for more detailed information. ```shell -curl -L -X PUT 'https://$CUSTOM-DOMAIN/v2beta/actions/executions' \ +curl -L -X PUT 'https://$CUSTOM-DOMAIN/v2/actions/executions' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ @@ -131,12 +139,12 @@ Now that you have set up the target and execution, you can test it by creating a by calling the ZITADEL API to create a human user. ```shell -curl -L -X PUT 'https://$CUSTOM-DOMAIN/v2/users/new' \ +curl -L -X POST 'https://$CUSTOM-DOMAIN/v2/users/new' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ --data-raw '{ - "organizationId": "336392597046099971", + "organizationId": "344648897353810062", "human": { "profile": @@ -150,7 +158,7 @@ curl -L -X PUT 'https://$CUSTOM-DOMAIN/v2/users/new' \ }, "email": { - "email": "mini@mouse.com" + "email": "mini+test@mouse.com" } } }' @@ -161,46 +169,50 @@ the [Sent information Request](./usage#sent-information-request) payload descrip ```json { - "fullMethod": "/zitadel.user.v2.UserService/CreateUser", - "instanceID": "336392597046034435", - "orgID": "336392597046099971", - "projectID": "336392597046165507", - "userID": "336392597046755331", - "request": + "fullMethod": "/zitadel.user.v2.UserService/CreateUser", + "instanceID": "344648897353744526", + "orgID": "344648897353810062", + "projectID": "344648897353875598", + "userID": "344648897354465422", + "request": + { + "organizationId": "344648897353810062", + "human": { - "organizationId": "336392597046099971", - "human": - { - "profile": - { - "givenName": "Minnie", - "familyName": "Mouse", - "nickName": "Mini", - "displayName": "Minnie Mouse", - "preferredLanguage": "en", - "gender": "GENDER_FEMALE" - }, - "email": - { - "email": "mini1@mouse.com" - } - } - }, - "headers": - { - "Content-Type": - [ - "application/grpc" - ], - "Host": - [ - "localhost:8080" - ], - "X-Forwarded-Host": - [ - "localhost:8080" - ] + "profile": + { + "givenName": "Minnie", + "familyName": "Mouse", + "nickName": "Mini", + "displayName": "Minnie Mouse", + "preferredLanguage": "en", + "gender": "GENDER_FEMALE" + }, + "email": + { + "email": "mini+test@mouse.com" + } } + }, + "headers": + { + "Content-Type": + [ + "application/grpc" + ], + "Host": + [ + "localhost:8080" + ], + "X-Forwarded-For": + [ + "::1" + ], + "X-Forwarded-Host": + [ + "localhost:8080" + ] + } } ``` diff --git a/docs/docs/guides/integrate/actions/testing-request.md b/docs/docs/guides/integrate/actions/testing-request.md index e2c9719ec..d2cee4f5f 100644 --- a/docs/docs/guides/integrate/actions/testing-request.md +++ b/docs/docs/guides/integrate/actions/testing-request.md @@ -78,7 +78,7 @@ As you see in the example above the target is created with HTTP and port '8090' See [Create a target](/apis/resources/action_service_v2/action-service-create-target) for more detailed information. ```shell -curl -L -X POST 'https://$CUSTOM-DOMAIN/v2beta/actions/targets' \ +curl -L -X POST 'https://$CUSTOM-DOMAIN/v2/actions/targets' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ @@ -102,7 +102,7 @@ condition. See [Set an execution](/apis/resources/action_service_v2/action-service-set-execution) for more detailed information. ```shell -curl -L -X PUT 'https://$CUSTOM-DOMAIN/v2beta/actions/executions' \ +curl -L -X PUT 'https://$CUSTOM-DOMAIN/v2/actions/executions' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ @@ -129,7 +129,7 @@ curl -L -X POST 'https://$CUSTOM-DOMAIN/v2/users/new' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ --data-raw '{ - "organizationId": "336392597046099971", + "organizationId": "344648897353810062", "human": { "profile": @@ -143,7 +143,7 @@ curl -L -X POST 'https://$CUSTOM-DOMAIN/v2/users/new' \ }, "email": { - "email": "mini@mouse.com" + "email": "mini+test@mouse.com" } } }' @@ -155,46 +155,50 @@ The incoming request headers to the Execution are propagated via the request pay ```json { - "fullMethod": "/zitadel.user.v2.UserService/CreateUser", - "instanceID": "336392597046034435", - "orgID": "336392597046099971", - "projectID": "336392597046165507", - "userID": "336392597046755331", - "request": + "fullMethod": "/zitadel.user.v2.UserService/CreateUser", + "instanceID": "344648897353744526", + "orgID": "344648897353810062", + "projectID": "344648897353875598", + "userID": "344648897354465422", + "request": + { + "organizationId": "344648897353810062", + "human": { - "organizationId": "336392597046099971", - "human": - { - "profile": - { - "givenName": "Minnie", - "familyName": "Mouse", - "nickName": "Mini", - "displayName": "Minnie Mouse", - "preferredLanguage": "en", - "gender": "GENDER_FEMALE" - }, - "email": - { - "email": "mini1@mouse.com" - } - } - }, - "headers": - { - "Content-Type": - [ - "application/grpc" - ], - "Host": - [ - "localhost:8080" - ], - "X-Forwarded-Host": - [ - "localhost:8080" - ] + "profile": + { + "givenName": "Minnie", + "familyName": "Mouse", + "nickName": "Mini", + "displayName": "Minnie Mouse", + "preferredLanguage": "en", + "gender": "GENDER_FEMALE" + }, + "email": + { + "email": "mini+test@mouse.com" + } } + }, + "headers": + { + "Content-Type": + [ + "application/grpc" + ], + "Host": + [ + "localhost:8080" + ], + "X-Forwarded-For": + [ + "::1" + ], + "X-Forwarded-Host": + [ + "localhost:8080" + ] + } } ``` diff --git a/docs/docs/guides/integrate/actions/testing-response-manipulation.md b/docs/docs/guides/integrate/actions/testing-response-manipulation.md index 24e4de384..bb7cd2ee3 100644 --- a/docs/docs/guides/integrate/actions/testing-response-manipulation.md +++ b/docs/docs/guides/integrate/actions/testing-response-manipulation.md @@ -144,7 +144,7 @@ target can be created as follows: See [Create a target](/apis/resources/action_service_v2/action-service-create-target) for more detailed information. ```shell -curl -L -X POST 'https://$CUSTOM-DOMAIN/v2beta/actions/targets' \ +curl -L -X POST 'https://$CUSTOM-DOMAIN/v2/actions/targets' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ @@ -168,7 +168,7 @@ we define an execution with a response condition. See [Set an execution](/apis/resources/action_service_v2/action-service-set-execution) for more detailed information. ```shell -curl -L -X PUT 'https://$CUSTOM-DOMAIN/v2beta/actions/executions' \ +curl -L -X PUT 'https://$CUSTOM-DOMAIN/v2/actions/executions' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ diff --git a/docs/docs/guides/integrate/actions/testing-response.md b/docs/docs/guides/integrate/actions/testing-response.md index dc53a3ca6..ed3fa1135 100644 --- a/docs/docs/guides/integrate/actions/testing-response.md +++ b/docs/docs/guides/integrate/actions/testing-response.md @@ -78,7 +78,7 @@ As you see in the example above the target is created with HTTP and port '8090' See [Create a target](/apis/resources/action_service_v2/action-service-create-target) for more detailed information. ```shell -curl -L -X POST 'https://$CUSTOM-DOMAIN/v2beta/actions/targets' \ +curl -L -X POST 'https://$CUSTOM-DOMAIN/v2/actions/targets' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ @@ -102,7 +102,7 @@ condition. See [Set an execution](/apis/resources/action_service_v2/action-service-set-execution) for more detailed information. ```shell -curl -L -X PUT 'https://$CUSTOM-DOMAIN/v2beta/actions/executions' \ +curl -L -X PUT 'https://$CUSTOM-DOMAIN/v2/actions/executions' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ @@ -129,7 +129,7 @@ curl -L -X POST 'https://$CUSTOM-DOMAIN/v2/users/new' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ --data-raw '{ - "organizationId": "336392597046099971", + "organizationId": "344648897353810062", "human": { "profile": @@ -156,13 +156,13 @@ The incoming request headers to the Execution are propagated via the request pay ```json { "fullMethod": "/zitadel.user.v2.UserService/CreateUser", - "instanceID": "336392597046034435", - "orgID": "336392597046099971", - "projectID": "336392597046165507", - "userID": "336392597046755331", + "instanceID": "344648897353744526", + "orgID": "344648897353810062", + "projectID": "344648897353875598", + "userID": "344648897354465422", "request": { - "organizationId": "336392597046099971", + "organizationId": "344648897353810062", "human": { "profile": @@ -195,6 +195,10 @@ The incoming request headers to the Execution are propagated via the request pay [ "localhost:8080" ], + "X-Forwarded-For": + [ + "::1" + ], "X-Forwarded-Host": [ "localhost:8080" diff --git a/docs/docs/guides/integrate/actions/webhook-site-setup.md b/docs/docs/guides/integrate/actions/webhook-site-setup.md index 434d944d7..05098e875 100644 --- a/docs/docs/guides/integrate/actions/webhook-site-setup.md +++ b/docs/docs/guides/integrate/actions/webhook-site-setup.md @@ -80,7 +80,7 @@ As shown in the example above, the target is created with HTTP and port '8090'. See [Create a target](/apis/resources/action_service_v2/action-service-create-target) for more detailed information. Notice that the `endpoint` is your Webhook.site URL. ```shell -curl -L -X POST 'https://$CUSTOM-DOMAIN/v2beta/actions/targets' \ +curl -L -X POST 'https://$CUSTOM-DOMAIN/v2/actions/targets' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ @@ -117,7 +117,7 @@ See [Set an execution](/apis/resources/action_service_v2/action-service-set-exec Here, `` is the `id` from the previous step. ```shell -curl -L -X PUT 'https://$CUSTOM-DOMAIN/v2beta/actions/executions' \ +curl -L -X PUT 'https://$CUSTOM-DOMAIN/v2/actions/executions' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \