> ## Documentation Index
> Fetch the complete documentation index at: https://docs.widgetic.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Report workflow events

> Public report of counts for a workflow, sent by the embed. No API key. Each event is one id and a number: a visitor reached a block (`n`), took a connection (`e`), or could not be moved on (`f`). Nothing else is kept: no visitor, no value a visitor typed, no address. A batch carries at most 100 events and 16 KB. The same report may carry `heights`: how tall a step settled at in the browser, which the embed code of the workflow uses to start its box at a real height (a composition, a whole number of pixels, nothing about the visitor).
A report is accepted only with the `token` the workflow's own read handed out for that `versionId`, so a page that never read the workflow cannot raise its numbers. An expired token (`EVENT_TOKEN_EXPIRED`) is refused with 401: read the workflow again for a new one. Counts for ids that are not in that version, or for a workflow that is not live, are not recorded and the answer says so (`recorded: false`) with 200: the visitor's page has nothing to fix.
The body is JSON, sent as `application/json` or as `text/plain` (a "simple" cross-origin request, which is what lets a report leave a page that is being closed).
**Address.** `https://api.widgetic.com/embed/workflows/{workflowId}/events`: the root of the API host, NOT under `/v1`. A client generated from this description for `https://api.widgetic.com/v1` must be given the base address `https://api.widgetic.com` for the calls of the `Public Embed` tag.



## OpenAPI

````yaml /openapi/widgetic-api-public.json post /embed/workflows/{workflowId}/events
openapi: 3.0.0
info:
  title: Widgetic API
  version: 1.0.0
  description: >-
    Create, publish and embed Widgetic widgets from your own code. Every request
    goes to `https://api.widgetic.com/v1` over HTTPS, with an API key as a
    bearer token.
  license:
    name: Widgetic Integration License
    url: https://docs.widgetic.com/resources/license
  termsOfService: https://widgetic.com/legal/terms
  contact:
    name: Widgetic developer support
    url: https://docs.widgetic.com/docs/introduction#need-help
servers:
  - url: https://api.widgetic.com/v1
    description: Production server
security: []
tags:
  - name: Widgets
    description: >-
      The reusable pieces compositions are made from. The widgets of your
      account are your own library.
  - name: Compositions
    description: >-
      A widget set up for one place: its content, design and embed settings, and
      what visitors sent to it.
  - name: Canvases
    description: >-
      The editing surface where a widget is designed and configured. A canvas
      holds one widget.
  - name: Workflows
    description: >-
      Compositions chained together, with filters that decide which one a
      visitor sees next.
  - name: A/B Testing
    description: >-
      Show two to four versions of a composition to different visitors, and see
      which one reaches the goal you chose.
  - name: Translations
    description: >-
      Copies of a composition in other languages, translated by a language
      model, and the views each language gets.
  - name: Uploads
    description: The files a workspace keeps, and the limits on what it accepts.
  - name: Brand Kit
    description: >-
      The colors, fonts, icons, corner radius and style notes every widget your
      account makes is generated with.
  - name: Tokens
    description: >-
      Check which account and workspace an API key belongs to, and what it may
      do.
  - name: Users
    description: The adapter connections of an account.
  - name: Credits
    description: The credits an account holds, and the ledger of how they were spent.
  - name: Organizations
    description: >-
      The websites a workspace lets its widgets appear on, the API keys of a
      workspace and the translations made in it.
  - name: Operations
    description: Follow work that carries on after the response that started it.
  - name: Partners
    description: >-
      Run Widgetic for your own customers: contract, billing, presets, storage,
      notifications, analytics and embeds. These endpoints need a partner key.
  - name: Managed Users
    description: >-
      The customers of a partner, with their editor sessions, limits and usage.
      Only partners can make and work with managed users, with an active partner
      API key.
  - name: Invoices
    description: The invoices issued to a partner.
  - name: Entitlements
    description: What a partner and its managed users are entitled to.
  - name: Public Embed
    description: >-
      What a published widget calls from a visitor's browser. These endpoints
      take no key.
externalDocs:
  description: Widgetic developer documentation
  url: https://docs.widgetic.com
paths:
  /embed/workflows/{workflowId}/events:
    servers:
      - url: https://api.widgetic.com
        description: >-
          The public embed routes are served at the root of the API host, not
          under /v1.
    post:
      tags:
        - Public Embed
      summary: Report what visitors did in a Workflow, as counts
      description: >-
        Public report of counts for a workflow, sent by the embed. No API key.
        Each event is one id and a number: a visitor reached a block (`n`), took
        a connection (`e`), or could not be moved on (`f`). Nothing else is
        kept: no visitor, no value a visitor typed, no address. A batch carries
        at most 100 events and 16 KB. The same report may carry `heights`: how
        tall a step settled at in the browser, which the embed code of the
        workflow uses to start its box at a real height (a composition, a whole
        number of pixels, nothing about the visitor).

        A report is accepted only with the `token` the workflow's own read
        handed out for that `versionId`, so a page that never read the workflow
        cannot raise its numbers. An expired token (`EVENT_TOKEN_EXPIRED`) is
        refused with 401: read the workflow again for a new one. Counts for ids
        that are not in that version, or for a workflow that is not live, are
        not recorded and the answer says so (`recorded: false`) with 200: the
        visitor's page has nothing to fix.

        The body is JSON, sent as `application/json` or as `text/plain` (a
        "simple" cross-origin request, which is what lets a report leave a page
        that is being closed).

        **Address.**
        `https://api.widgetic.com/embed/workflows/{workflowId}/events`: the root
        of the API host, NOT under `/v1`. A client generated from this
        description for `https://api.widgetic.com/v1` must be given the base
        address `https://api.widgetic.com` for the calls of the `Public Embed`
        tag.
      operationId: reportPublicWorkflowEvents
      parameters:
        - in: path
          name: workflowId
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PublicWorkflowEventsRequest'
          text/plain:
            schema:
              type: string
              description: The same JSON, as text.
      responses:
        '200':
          description: Nothing was counted or kept (`recorded` is false, with the reason)
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - data
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/PublicWorkflowEventsAccepted'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '202':
          description: The counts were recorded
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - data
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/PublicWorkflowEventsAccepted'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          description: >-
            The body is not what the door reads (`EVENTS_BODY_INVALID`, or a
            field that is not valid)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicEmbedFailure'
        '401':
          description: >-
            The token is missing, wrong, or expired (`EVENT_TOKEN_REQUIRED`,
            `EVENT_TOKEN_INVALID`, `EVENT_TOKEN_EXPIRED`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicEmbedFailure'
        '404':
          description: >-
            The workflow's owner is not being served, so no count is taken
            (`SUSPENDED` for a partner whose agreement is not in force,
            `NOT_FOUND` with the subscription sentence for a plan that lapsed).
            Dropping the counts is fine.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicEmbedFailure'
        '413':
          description: Body too large (`PAYLOAD_TOO_LARGE`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicEmbedFailure'
        '415':
          description: Not JSON or plain text (`UNSUPPORTED_MEDIA_TYPE`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicEmbedFailure'
        '429':
          description: Rate limited (`RATE_LIMITED`), always with `Retry-After`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicEmbedFailure'
        '503':
          description: >-
            Counts cannot be recorded right now (`EVENT_TOKEN_UNAVAILABLE`, or
            `SERVICE_UNAVAILABLE`). Dropping them is fine.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicEmbedFailure'
      servers:
        - url: https://api.widgetic.com
          description: Production server
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl --request POST \
              --url 'https://api.widgetic.com/embed/workflows/123e4567-e89b-12d3-a456-426614174000/events' \
              --header 'Content-Type: application/json' \
              --data '{
              "versionId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
              "token": "Example token",
              "events": [
                {
                  "k": "n",
                  "id": "example",
                  "c": 1,
                  "r": "t"
                }
              ],
              "heights": [
                {
                  "compositionId": "123e4567-e89b-12d3-a456-426614174000",
                  "height": 1
                }
              ]
            }'
        - lang: typescript
          label: TypeScript
          source: >-
            import { Configuration, PublicEmbedApi } from
            '@widgetic/api-sdk-ts';


            const publicEmbedApi = new PublicEmbedApi(new Configuration({
            basePath: 'https://api.widgetic.com' }));


            const result = await publicEmbedApi.reportPublicWorkflowEvents({
              workflowId: '123e4567-e89b-12d3-a456-426614174000',
              publicWorkflowEventsRequest: {
                versionId: '3fa85f64-5717-4562-b3fc-2c963f66afa6',
                token: 'Example token',
                events: [
                  {
                    k: 'n',
                    id: 'example',
                    c: 1,
                    r: 't',
                  },
                ],
                heights: [
                  {
                    compositionId: '123e4567-e89b-12d3-a456-426614174000',
                    height: 1,
                  },
                ],
              },
            });

            console.log(result);
        - lang: python
          label: Python
          source: >-
            import api_sdk_py


            configuration =
            api_sdk_py.Configuration(host="https://api.widgetic.com")


            with api_sdk_py.ApiClient(configuration) as api_client:
                public_embed_api = api_sdk_py.PublicEmbedApi(api_client)
                result = public_embed_api.report_public_workflow_events(
                    workflow_id="123e4567-e89b-12d3-a456-426614174000",
                    public_workflow_events_request={
                        "versionId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
                        "token": "Example token",
                        "events": [
                            {
                                "k": "n",
                                "id": "example",
                                "c": 1,
                                "r": "t",
                            },
                        ],
                        "heights": [
                            {
                                "compositionId": "123e4567-e89b-12d3-a456-426614174000",
                                "height": 1,
                            },
                        ],
                    },
                )
                print(result)
        - lang: go
          label: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\n\twidgetic \"github.com/widgetic/api-sdk-go\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tconfiguration := widgetic.NewConfiguration()\n\tconfiguration.Servers = widgetic.ServerConfigurations{{URL: \"https://api.widgetic.com\"}}\n\tclient := widgetic.NewAPIClient(configuration)\n\n\tpublicWorkflowEventsRequestJSON := `{\n  \"versionId\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n  \"token\": \"Example token\",\n  \"events\": [\n    {\n      \"k\": \"n\",\n      \"id\": \"example\",\n      \"c\": 1,\n      \"r\": \"t\"\n    }\n  ],\n  \"heights\": [\n    {\n      \"compositionId\": \"123e4567-e89b-12d3-a456-426614174000\",\n      \"height\": 1\n    }\n  ]\n}`\n\tvar publicWorkflowEventsRequest widgetic.PublicWorkflowEventsRequest\n\tif err := json.Unmarshal([]byte(publicWorkflowEventsRequestJSON), &publicWorkflowEventsRequest); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tresult, _, err := client.PublicEmbedAPI.ReportPublicWorkflowEvents(ctx, \"123e4567-e89b-12d3-a456-426614174000\").\n\t\tPublicWorkflowEventsRequest(publicWorkflowEventsRequest).\n\t\tExecute()\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, err)\n\t\tos.Exit(1)\n\t}\n\tfmt.Println(result)\n}"
        - lang: java
          label: Java
          source: |-
            import com.widgetic.api.ApiClient;
            import com.widgetic.api.ApiException;
            import com.widgetic.api.Configuration;
            import com.widgetic.api.JSON;
            import com.widgetic.api.api.PublicEmbedApi;
            import com.widgetic.api.model.PublicWorkflowEventsRequest;
            import java.util.UUID;

            public class Example {
                public static void main(String[] args) throws ApiException {
                    ApiClient client = Configuration.getDefaultApiClient();
                    client.setBasePath("https://api.widgetic.com");

                    PublicEmbedApi publicEmbedApi = new PublicEmbedApi(client);

                    String publicWorkflowEventsRequestJson = """
                            {
                              "versionId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
                              "token": "Example token",
                              "events": [
                                {
                                  "k": "n",
                                  "id": "example",
                                  "c": 1,
                                  "r": "t"
                                }
                              ],
                              "heights": [
                                {
                                  "compositionId": "123e4567-e89b-12d3-a456-426614174000",
                                  "height": 1
                                }
                              ]
                            }
                            """;
                    PublicWorkflowEventsRequest publicWorkflowEventsRequest = JSON.deserialize(publicWorkflowEventsRequestJson, PublicWorkflowEventsRequest.class);

                    var result = publicEmbedApi.reportPublicWorkflowEvents(
                        UUID.fromString("123e4567-e89b-12d3-a456-426614174000"),
                        publicWorkflowEventsRequest
                    );
                    System.out.println(result);
                }
            }
        - lang: csharp
          label: C#
          source: >-
            using System;

            using Newtonsoft.Json;

            using Widgetic.ApiSdk.Cs.Api;

            using Widgetic.ApiSdk.Cs.Client;

            using Widgetic.ApiSdk.Cs.Model;


            var configuration = new Configuration

            {
                BasePath = "https://api.widgetic.com",
            };

            var publicEmbedApi = new PublicEmbedApi(configuration);


            var publicWorkflowEventsRequest =
            JsonConvert.DeserializeObject<PublicWorkflowEventsRequest>("""
                {
                  "versionId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
                  "token": "Example token",
                  "events": [
                    {
                      "k": "n",
                      "id": "example",
                      "c": 1,
                      "r": "t"
                    }
                  ],
                  "heights": [
                    {
                      "compositionId": "123e4567-e89b-12d3-a456-426614174000",
                      "height": 1
                    }
                  ]
                }
                """)!;

            var result = publicEmbedApi.ReportPublicWorkflowEvents(
                workflowId: Guid.Parse("123e4567-e89b-12d3-a456-426614174000"),
                publicWorkflowEventsRequest: publicWorkflowEventsRequest
            );

            Console.WriteLine(result);
        - lang: ruby
          label: Ruby
          source: |-
            require 'api-sdk-rb'

            ApiSdkRb.configure do |config|
              config.host = 'api.widgetic.com'
              config.base_path = ''
            end

            public_embed_api = ApiSdkRb::PublicEmbedApi.new

            result = public_embed_api.report_public_workflow_events(
              '123e4567-e89b-12d3-a456-426614174000',
              {
                versionId: '3fa85f64-5717-4562-b3fc-2c963f66afa6',
                token: 'Example token',
                events: [
                  {
                    k: 'n',
                    id: 'example',
                    c: 1,
                    r: 't'
                  }
                ],
                heights: [
                  {
                    compositionId: '123e4567-e89b-12d3-a456-426614174000',
                    height: 1
                  }
                ]
              }
            )
            puts result
        - lang: php
          label: PHP
          source: >-
            <?php


            require_once __DIR__ . '/vendor/autoload.php';


            use WidgeticApi\Api\PublicEmbedApi;

            use WidgeticApi\Configuration;

            use WidgeticApi\Model\PublicWorkflowEventsRequest;

            use WidgeticApi\ObjectSerializer;


            $config =
            Configuration::getDefaultConfiguration()->setHost('https://api.widgetic.com');

            $publicEmbedApi = new PublicEmbedApi(new GuzzleHttp\Client(),
            $config);


            $publicWorkflowEventsRequestJson = '{
              "versionId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
              "token": "Example token",
              "events": [
                {
                  "k": "n",
                  "id": "example",
                  "c": 1,
                  "r": "t"
                }
              ],
              "heights": [
                {
                  "compositionId": "123e4567-e89b-12d3-a456-426614174000",
                  "height": 1
                }
              ]
            }';

            $publicWorkflowEventsRequest =
            ObjectSerializer::deserialize(json_decode($publicWorkflowEventsRequestJson),
            PublicWorkflowEventsRequest::class);


            $result = $publicEmbedApi->reportPublicWorkflowEvents(
                workflow_id: '123e4567-e89b-12d3-a456-426614174000',
                public_workflow_events_request: $publicWorkflowEventsRequest,
            );

            print_r($result);
components:
  schemas:
    PublicWorkflowEventsRequest:
      type: object
      description: >
        One report from a visitor's browser: counts (`events`), the heights
        steps settled at (`heights`), or both. A report

        with neither is refused.
      required:
        - versionId
        - token
      properties:
        versionId:
          type: string
          format: uuid
        token:
          type: string
          description: The `eventToken` of the workflow, read for the same version.
        events:
          type: array
          maxItems: 100
          description: >-
            The counts of what visitors did. At least one of `events` and
            `heights` is needed.
          items:
            type: object
            required:
              - k
              - id
            properties:
              k:
                type: string
                enum:
                  - 'n'
                  - e
                  - f
                description: >-
                  `n` a visitor reached a block, `e` a visitor took a
                  connection, `f` moving a visitor on failed.
              id:
                type: string
                pattern: ^[A-Za-z0-9_-]{1,64}$
                description: The block or connection counted.
              c:
                type: integer
                minimum: 1
                maximum: 50
                description: How many times (1 when not given).
              r:
                type: string
                enum:
                  - t
                  - e
                  - b
                  - o
                description: >
                  Only on an `f` event: why moving the visitor on failed. `t`
                  the composition did not appear in time,

                  `e` the widget in it reported an error, `b` the composition
                  could not be built, `o` another reason (a

                  step was already on its way, or the page was going away). Left
                  out by an embed that does not say why;

                  a letter this server does not know is read as left out, and
                  the failure is still counted. On an `n` or

                  an `e` event it is ignored. Never a message: one letter, so
                  that nothing a visitor typed can ride on it.
        heights:
          type: array
          maxItems: 10
          description: >
            How tall steps of this version settled in the visitor's browser, so
            that the embed code of the workflow can

            start its box at the height visitors saw instead of a guess. The
            Embed SDK sends one for a visitor who has no

            remembered height for the step. The gateway keeps the latest few for
            each composition (the median is what the

            code gets); a composition that this version does not show is left
            out. At least one of `events` and `heights`

            is needed.
          items:
            type: object
            required:
              - compositionId
              - height
            properties:
              compositionId:
                type: string
                format: uuid
                description: The composition the step shows.
              height:
                type: integer
                minimum: 1
                maximum: 100000
                description: >-
                  The height the step settled at, in pixels. One under 100 is
                  not kept, one over 2000 is kept as 2000.
      example:
        versionId: 3fa85f64-5717-4562-b3fc-2c963f66afa6
        token: Example token
        events: []
        heights: []
    PublicWorkflowEventsAccepted:
      type: object
      required:
        - recorded
      properties:
        recorded:
          type: boolean
          description: >-
            False when nothing was counted or kept (the workflow is not live any
            more, or the ids are not in that version).
        counters:
          type: integer
          description: How many counters were raised (0 for a report of heights alone).
        reason:
          type: string
          description: Why nothing was counted or kept, when `recorded` is false.
      example:
        recorded: true
        counters: 42
        reason: Example reason
    ResponseMeta:
      type: object
      description: >-
        Extra information about the answer: where a page sits in a list, the
        cursor of the next page, or warnings about a call that succeeded with a
        caveat.
      additionalProperties: true
      properties:
        page:
          type: integer
          description: The page that was read, counting from 1.
          example: 1
        size:
          type: integer
          description: How many items one page holds.
          example: 20
        total:
          type: integer
          description: How many items the whole list has.
          example: 135
        limit:
          type: integer
          description: The same as `size`.
          example: 20
        offset:
          type: integer
          description: How many items come before this page.
          example: 0
        hasNextPage:
          type: boolean
          example: true
        hasPreviousPage:
          type: boolean
          example: false
        nextCursor:
          type: string
          nullable: true
          description: >-
            Pass this as `cursor` to read the next page of a list that is read
            by cursor. `null` on the last page.
        warnings:
          type: array
          items:
            type: string
          description: >-
            Things the call did not do, though it succeeded (for example a table
            that could not be created just now).
    PublicEmbedFailure:
      type: object
      required:
        - success
        - message
        - error
        - code
      description: >-
        What a public embed route answers when it refuses or fails. It is the
        standard error answer of the API (`success`, `message`, `error`), and
        the short `code` (with `details` and `correlationId` when the route has
        them) is also at the top level, because a page that embeds a composition
        branches on it there. `error.code` is the same word in the codes of the
        rest of the API where those have it: `NOT_FOUND` is
        `RESOURCE_NOT_FOUND`, `RATE_LIMITED` is `RATE_LIMIT_EXCEEDED`, and the
        others (`DOMAIN_NOT_ALLOWED`, `UNPUBLISHED`, `SUSPENDED`, the codes of
        the entry route) are the same in both places.
      properties:
        success:
          type: boolean
          enum:
            - false
        message:
          type: string
          description: What happened, for a person.
        code:
          type: string
          description: >-
            The short code a page branches on: `DOMAIN_NOT_ALLOWED`,
            `UNPUBLISHED`, `SUSPENDED`, `NOT_FOUND`, `RATE_LIMITED`, and for the
            entry route the codes listed with its answers.
          example: NOT_FOUND
        details:
          type: object
          additionalProperties: true
          description: >-
            What tells the cases of one code apart, such as `reason` of
            `DOMAIN_NOT_ALLOWED`.
          properties:
            reason:
              type: string
              description: For `DOMAIN_NOT_ALLOWED`, why the website was refused.
              enum:
                - domain_not_allowed
                - opaque_origin
            hasDomainsConfigured:
              type: boolean
              description: >-
                For `DOMAIN_NOT_ALLOWED`, always true (an owner who listed
                nothing is never refused).
        correlationId:
          type: string
          description: The id of the request, for the routes that carry it.
        error:
          type: object
          required:
            - code
            - message
            - timestamp
          properties:
            code:
              type: string
              example: RESOURCE_NOT_FOUND
            message:
              type: string
            details:
              type: object
              additionalProperties: true
            correlationId:
              type: string
            retryAfter:
              type: integer
              description: Seconds to wait before asking again, for a rate-limit refusal.
            timestamp:
              type: string
              format: date-time
      example:
        success: true
        message: Example message
        code: NOT_FOUND
        details: {}
        correlationId: Example correlationId
        error: {}

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.