Create or Update Events from Your CRM

Create an Event from a CRM record (for example Salesforce, HubSpot or Zoho CRM), or update the Event already linked to it.

Example use case

Your CRM has a confirmed show. You want to set up its planning section and Exhibit Hall schedule, then keep the linked Event's name and main dates in sync.

What you'll end up with

A verified link to one ExhibitDay Event and its planning section, plus the saved Exhibit Hall schedule.

Before you start

Have an API key that can read the workspace and perform the setup changes, a stable CRM key, and the complete Exhibit Hall schedule you want to save.

This guide stores your system's ID for each Event in integration_metadata_field_1, one of five API-only text fields on each Event. If another integration already uses field 1, choose a free field (1 to 5) and use it consistently.

Good to know

This works with any CRM that can call a web API or use an automation tool (like Zapier, Make or Pipedream); no special connector is needed.

At a glance

Time to try

About 20 minutes

Effect on your data

Creates and updates

Endpoints

10

The program may create an Event or Task Section, update a linked Event's name or main dates, and replace the Exhibit Hall Dates group. It also writes a private local journal.

How it works

  1. Each show in your CRM has a stable ID. If the search finds no match, the program creates the Event and saves that ID in integration_metadata_field_1.
  2. On later runs, it looks up the Event by that ID, so renaming the show keeps the records linked.
  3. If the CRM name or main dates differ, it updates only those fields after checking the Event's revision.
  4. It finds or creates the planning Task Section and saves the complete Exhibit Hall schedule if it differs.
  5. It records save attempts in a private local journal and checks what happened before continuing a stopped run.

Set up the Event

The examples below follow an Event that already exists. Step 3 applies only when the Event search finds no match. Step 8 applies only when the Task Section search finds no match.

Step 1: Confirm the workspace

Read the workspace summary to check where the key will make changes.

curl -X GET "https://api.exhibitday.com/v1/references/workspace_info" -H "Authorization: Bearer YOUR_API_KEY"

Example response (shortened)

{
  "id": 98765
}

Check: Confirm id belongs to the workspace you intended to use.

Step 2: Find the linked Event

Search Events by integration_metadata_field_1, the field where your CRM ID is stored, so a name change will not break the link.

curl -X GET "https://api.exhibitday.com/v1/events?filter_by_integration_metadata_field_1=crm%3Aevent%3Aspring-expo-2030&%24limit=100&%24offset=0" -H "Authorization: Bearer YOUR_API_KEY"

Example response (shortened)

{
  "records_found": 1,
  "total_records": 1,
  "has_more": false,
  "list_data": [
    {
      "id": 5001,
      "name": "Spring Expo",
      "integration_metadata_field_1": "crm:event:spring-expo-2030"
    }
  ]
}

Check: Read every page and compare the saved key exactly. Continue with one distinct match, create with zero, or stop and investigate if there are several.

Step 3: Create the Event if the search found none

Send the CRM values and external key to create the first linked Event.

curl -X POST "https://api.exhibitday.com/v1/events" -H "Authorization: Bearer YOUR_API_KEY" -H "Idempotency-Key: YOUR_EVENT_CREATE_KEY" -H "Content-Type: application/json" --data-binary "{\"name\":\"Spring Expo 2030\",\"start_date\":\"2030-01-14\",\"end_date\":\"2030-01-16\",\"integration_metadata_field_1\":\"crm:event:spring-expo-2030\"}"

Example response (shortened)

{
  "id": 5001,
  "name": "Spring Expo 2030",
  "start_date": "2030-01-14",
  "end_date": "2030-01-16",
  "integration_metadata_field_1": "crm:event:spring-expo-2030"
}

Check: Keep the returned id and confirm the key, name and dates. The program saves the create key in its journal before sending the request.

Step 4: Read the Event and its revision

Read the selected Event by ID so you can check the exact link and compare its current values.

curl -X GET "https://api.exhibitday.com/v1/events/info?id=5001&%24include_record_revision=true" -H "Authorization: Bearer YOUR_API_KEY"

Example response (shortened)

{
  "id": 5001,
  "name": "Spring Expo",
  "start_date": "2030-01-14",
  "end_date": "2030-01-15",
  "integration_metadata_field_1": "crm:event:spring-expo-2030",
  "record_revision": "COPY_EVENT_REVISION_FROM_YOUR_READ"
}

Check: Compare the ID and key. Save record_revision for the next request if an update is needed. The revision below is a placeholder.

Step 5: Update the linked Event if values differ

For an existing linked Event, send only the changed values and the revision from the previous read.

curl -X PATCH "https://api.exhibitday.com/v1/events" -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" --data-binary "{\"id\":5001,\"name\":\"Spring Expo 2030\",\"end_date\":\"2030-01-16\",\"expected_revision\":\"COPY_EVENT_REVISION_FROM_YOUR_READ\"}"

Example response (shortened)

{
  "status_code": 200,
  "status": "OK",
  "message": "Event Update Successful. Event properties that were changed: name, end_date",
  "record_revision": "NEW_EVENT_REVISION"
}

Check: In this example, name and end_date changed, so start_date is omitted. A successful conditional update returns a new record_revision.

Step 6: Verify the Event before continuing

Read the Event again so the setup only continues when the actual values match the CRM values.

curl -X GET "https://api.exhibitday.com/v1/events/info?id=5001" -H "Authorization: Bearer YOUR_API_KEY"

Example response (shortened)

{
  "id": 5001,
  "name": "Spring Expo 2030",
  "start_date": "2030-01-14",
  "end_date": "2030-01-16",
  "integration_metadata_field_1": "crm:event:spring-expo-2030"
}

Check: Check the ID, integration key, name, start date and end date. The example also checks these values if no update was needed.

Step 7: Find the planning section

Read this Event's Task Sections and look for the exact section name.

curl -X GET "https://api.exhibitday.com/v1/tasks/sections?filter_by_event_id=5001&%24limit=100&%24offset=0" -H "Authorization: Bearer YOUR_API_KEY"

Example response (shortened)

{
  "records_found": 1,
  "total_records": 1,
  "has_more": false,
  "list_data": [
    {
      "id": 6001,
      "event_id": 5001,
      "name": "Pre-event planning"
    }
  ]
}

Check: Read all matching pages. Use one exact match, create with zero, or stop if there are several.

Step 8: Create the section if none matched

Send the section name with the saved Event ID to add it to this Event.

curl -X POST "https://api.exhibitday.com/v1/tasks/sections" -H "Authorization: Bearer YOUR_API_KEY" -H "Idempotency-Key: YOUR_SECTION_CREATE_KEY" -H "Content-Type: application/json" --data-binary "{\"event_id\":5001,\"name\":\"Pre-event planning\"}"

Example response (shortened)

{
  "id": 6001,
  "event_id": 5001,
  "name": "Pre-event planning"
}

Check: Keep the section id and confirm event_id. The section create uses its own saved idempotency key.

Step 9: Verify the section

Read the selected Task Section by ID to confirm its saved details.

curl -X GET "https://api.exhibitday.com/v1/tasks/sections/info?id=6001" -H "Authorization: Bearer YOUR_API_KEY"

Example response (shortened)

{
  "id": 6001,
  "event_id": 5001,
  "name": "Pre-event planning"
}

Check: Check the section ID, Event ID and name before continuing.

Step 10: Read the complete Exhibit Hall Dates group

Read date type 1 with its revision so the program can replace that specific group safely.

curl -X GET "https://api.exhibitday.com/v1/events/dates?event_id=5001&filter_by_date_type_id=1&%24include_record_revision=true" -H "Authorization: Bearer YOUR_API_KEY"

Example response (shortened)

{
  "records_found": 1,
  "total_records": 1,
  "has_more": false,
  "list_data": [
    {
      "event_id": 5001,
      "date_type_id": 1,
      "dates": [
        {
          "date": "2030-01-15",
          "start_time": "09:00:00",
          "end_time": "15:00:00",
          "timezone": "America/New_York",
          "description": "Earlier exhibit schedule"
        }
      ],
      "record_revision": "COPY_DATES_REVISION_FROM_YOUR_READ"
    }
  ]
}

Check: Confirm the Event and date type in the one returned group. Use that group's record_revision for the Dates update. The revision below is a placeholder.

Step 11: Save the complete Exhibit Hall schedule

Replace the group with every date and time you want to keep, using the Dates revision.

curl -X PATCH "https://api.exhibitday.com/v1/events/dates" -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" --data-binary "{\"event_id\":5001,\"date_type_id\":1,\"dates\":[{\"date\":\"2030-01-15\",\"start_time\":\"09:00:00\",\"end_time\":\"17:00:00\",\"timezone\":\"America/New_York\",\"description\":\"Exhibit hours\"},{\"date\":\"2030-01-16\",\"start_time\":\"09:00:00\",\"end_time\":\"16:00:00\",\"timezone\":\"America/New_York\",\"description\":\"Final exhibit day\"}],\"expected_revision\":\"COPY_DATES_REVISION_FROM_YOUR_READ\"}"

Example response (shortened)

{
  "status_code": 200,
  "status": "OK",
  "message": "Event Dates updated.",
  "record_revision": "NEW_DATES_REVISION"
}

Check: Look for the saved record_revision. Dates you leave out are removed from this group, so include every date you want to keep.

Step 12: Verify the saved schedule

Read the group again to check that the complete saved schedule matches what you sent.

curl -X GET "https://api.exhibitday.com/v1/events/dates?event_id=5001&filter_by_date_type_id=1" -H "Authorization: Bearer YOUR_API_KEY"

Example response (shortened)

{
  "records_found": 1,
  "total_records": 1,
  "has_more": false,
  "list_data": [
    {
      "event_id": 5001,
      "date_type_id": 1,
      "dates": [
        {
          "date": "2030-01-15",
          "start_time": "09:00:00",
          "end_time": "17:00:00",
          "timezone": "America/New_York",
          "description": "Exhibit hours"
        },
        {
          "date": "2030-01-16",
          "start_time": "09:00:00",
          "end_time": "16:00:00",
          "timezone": "America/New_York",
          "description": "Final exhibit day"
        }
      ]
    }
  ]
}

Check: Compare each date, local time, time-zone label and description in the order the API returns them.

Step 13: Confirm the final Event setup

Read the Event again to verify its CRM link and planning section after the separate saves.

curl -X GET "https://api.exhibitday.com/v1/events/info?id=5001" -H "Authorization: Bearer YOUR_API_KEY"

Example response (shortened)

{
  "id": 5001,
  "name": "Spring Expo 2030",
  "start_date": "2030-01-14",
  "end_date": "2030-01-16",
  "integration_metadata_field_1": "crm:event:spring-expo-2030",
  "task_sections": [
    {
      "id": 6001,
      "name": "Pre-event planning",
      "display_rank": 0
    },
    {
      "id": 6002,
      "name": "Onsite follow-up",
      "display_rank": 1
    }
  ]
}

Check: Confirm the ID, key, name and dates, and find the saved section ID in task_sections.

Try it

Before running the example

VariableWhat to put in itRequired?
EXHIBITDAY_API_KEYYour workspace API key.Yes
EXHIBITDAY_EXTERNAL_EVENT_KEYA stable CRM key, up to 3,000 UTF-16 code units. Leave no whitespace at either end.Yes
EXHIBITDAY_EVENT_NAMEThe Event name, up to 500 UTF-16 code units. Use plain, single-line text with no surrounding whitespace.Yes
EXHIBITDAY_START_DATEThe main start date in YYYY-MM-DD format.Yes
EXHIBITDAY_END_DATEThe main end date in YYYY-MM-DD format, on or after the start date.Yes
EXHIBITDAY_EXHIBIT_DATES_JSONThe entire desired Exhibit Hall Dates array. Use all five fields per entry, including normalized times such as 09:00:00, in the order returned by the API.Yes
EXHIBITDAY_JOURNALA private local journal path for this setup.Yes
EXHIBITDAY_JOB_IDA stable ID for this setup. Keep it for a resume.Yes
EXHIBITDAY_TASK_SECTION_NAMEThe exact name to find or create. The default is Pre-event planning.No
EXHIBITDAY_PAGE_SIZEThe page size for the searches. The default is 100.No
EXHIBITDAY_JOB_MODEUse new for a new job or resume for the existing journal. The default is resume.No

Bash

export EXHIBITDAY_API_KEY='YOUR_API_KEY'
export EXHIBITDAY_EXTERNAL_EVENT_KEY='crm:event:spring-expo-2030'
export EXHIBITDAY_EVENT_NAME='Spring Expo 2030'
export EXHIBITDAY_START_DATE='2030-01-14'
export EXHIBITDAY_END_DATE='2030-01-16'
export EXHIBITDAY_EXHIBIT_DATES_JSON='[{"date":"2030-01-15","start_time":"09:00:00","end_time":"17:00:00","timezone":"America/New_York","description":"Exhibit hours"},{"date":"2030-01-16","start_time":"09:00:00","end_time":"16:00:00","timezone":"America/New_York","description":"Final exhibit day"}]'

PowerShell

$env:EXHIBITDAY_API_KEY = 'YOUR_API_KEY'
$env:EXHIBITDAY_EXTERNAL_EVENT_KEY = 'crm:event:spring-expo-2030'
$env:EXHIBITDAY_EVENT_NAME = 'Spring Expo 2030'
$env:EXHIBITDAY_START_DATE = '2030-01-14'
$env:EXHIBITDAY_END_DATE = '2030-01-16'
$env:EXHIBITDAY_EXHIBIT_DATES_JSON = '[{"date":"2030-01-15","start_time":"09:00:00","end_time":"17:00:00","timezone":"America/New_York","description":"Exhibit hours"},{"date":"2030-01-16","start_time":"09:00:00","end_time":"16:00:00","timezone":"America/New_York","description":"Final exhibit day"}]'

Set a private journal path and a stable job ID. For the first run, set EXHIBITDAY_JOB_MODE=new. Then copy and run the complete example in your language.

Complete example program

Code Samples
#!/usr/bin/env bash
# Requires Bash, curl and Python3. No API key is written into the program.
python3 - <<'EXHIBITDAY_PY'
# Python 3; standard library only. Set EXHIBITDAY_API_KEY before running.
import http.client
import json
import os
import re
import time
import urllib.error
import urllib.parse
import urllib.request

BASE = "https://api.exhibitday.com/v1"
SPEC = json.loads("{\"preserveNumbers\":true,\"requests\":{\"workspace_binding\":{\"method\":\"GET\",\"path\":\"/references/workspace_info\"},\"find_existing\":{\"method\":\"GET\",\"path\":\"/events\"},\"create_event\":{\"method\":\"POST\",\"path\":\"/events\"},\"confirm_event\":{\"method\":\"GET\",\"path\":\"/events/info\"},\"update_event\":{\"method\":\"PATCH\",\"path\":\"/events\"},\"verify_event_update\":{\"method\":\"GET\",\"path\":\"/events/info\"},\"find_section\":{\"method\":\"GET\",\"path\":\"/tasks/sections\"},\"create_section\":{\"method\":\"POST\",\"path\":\"/tasks/sections\"},\"confirm_section\":{\"method\":\"GET\",\"path\":\"/tasks/sections/info\"},\"read_dates\":{\"method\":\"GET\",\"path\":\"/events/dates\"},\"save_dates\":{\"method\":\"PATCH\",\"path\":\"/events/dates\"},\"verify_dates\":{\"method\":\"GET\",\"path\":\"/events/dates\"},\"event_readback\":{\"method\":\"GET\",\"path\":\"/events/info\"}}}")
API_KEY = os.environ["EXHIBITDAY_API_KEY"]
if any(ord(char) < 32 or ord(char) > 126 for char in API_KEY):
    raise RuntimeError("Use the API key as one ASCII header value without control characters")
if not API_KEY.strip():
    raise RuntimeError("Set EXHIBITDAY_API_KEY")

def decode_json(text):
    if SPEC["preserveNumbers"]:
        # Quote JSON NUMBER tokens, never text inside a JSON string, to keep CSV decimals exact.
        text = re.sub(r'"(?:\\.|[^"\\])*"|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?',
                      lambda m: m[0] if m[0].startswith('"') else json.dumps(m[0]), text)
    return json.loads(text)

from pathlib import Path
# This terminal version uses curl for HTTP and Python's standard library for JSON/CSV.
import subprocess
import tempfile

def transport(method, url, headers, data):
    with tempfile.TemporaryDirectory(prefix="exhibitday-guide-") as directory:
        folder = Path(directory)
        # curl may leave no output file for a valid bodyless304 response.
        (folder / "body").write_bytes(b"")
        command = ["curl", "--disable", "--silent", "--show-error", "--request", method, "--url", url,
                   "--max-time", "30", "--dump-header", str(folder / "headers"),
                   "--output", str(folder / "body"), "--write-out", "%{http_code}"]
        for name, value in headers.items():
            command += ["--header", name + ": " + value]
        if data is not None:
            (folder / "request").write_bytes(data)
            command += ["--data-binary", "@" + str(folder / "request")]
        result = subprocess.run(command, capture_output=True, text=True)
        if result.returncode:
            raise urllib.error.URLError(result.stderr.strip())
        response_headers = {}
        blocks = (folder / "headers").read_text(encoding="iso-8859-1").replace("\r\n", "\n").strip().split("\n\n")
        for line in blocks[-1].splitlines()[1:]:
            name, separator, value = line.partition(":")
            if separator:
                response_headers[name] = value.strip()
        return int(result.stdout), (folder / "body").read_bytes(), response_headers


class ApiError(RuntimeError):
    """An API error response. Branch on error_code (and status), never on the message text.
    uncertain is True when a PATCH or DELETE got no response or a server error: it may or may not have been applied."""
    def __init__(self, status, body, uncertain=False):
        self.status = status
        self.uncertain = uncertain
        self.error_code = body.get("error_code") if isinstance(body, dict) else None
        super().__init__(f"{body.get('error_code')} {body.get('error_params')}: {body.get('errors')} (request {body.get('request_id')})"
                         if isinstance(body, dict) else "HTTP " + str(status) if status else "No response")

def call(name, params=None, body=None, key=None):
    route = SPEC["requests"][name]
    headers = {"Authorization": "Bearer " + API_KEY, "Accept": "application/json"}
    if route["method"] == "POST":
        if not key: raise RuntimeError("Persist a logical create key before sending POST")
        headers["Idempotency-Key"] = key
    data = None if body is None else json.dumps(body).encode("utf-8")
    if data is not None:
        headers["Content-Type"] = "application/json"
    query = urllib.parse.urlencode(params or {})
    url = BASE + route["path"] + ("?" + query if query else "")
    # Only GET has automatic retries in this workflow. A PATCH or DELETE that got no response or a
    # server error is never resent blindly: it may already have been applied, so the caller reads the record first.
    resend = route["method"] == "GET"
    for attempt in range(5):
        try:
            status, raw, response_headers = transport(route["method"], url, headers, data)
        except (urllib.error.URLError, TimeoutError, ConnectionError, http.client.HTTPException):
            if not resend:
                raise ApiError(0, None, uncertain=True)
            if attempt == 4:
                raise
            time.sleep(2 ** attempt)
            continue
        response_headers = {k.lower(): v for k, v in response_headers.items()}
        result = None
        if status != 304 and raw:
            try:
                result = decode_json(raw.decode("utf-8"))
            except (ValueError, UnicodeError):
                if status < 400:
                    raise RuntimeError("Expected a JSON success response")
        if status >= 500 and not resend:
            raise ApiError(status, result, uncertain=True)
        retry = resend and (status == 429 or status >= 500)
        if retry:
            if attempt == 4:
                raise RuntimeError("Retry limit reached; check the request outcome before starting a new create")
            delay = response_headers.get("retry-after", str(2 ** attempt))
            time.sleep(max(0, float(delay)))
            continue
        if status >= 400:
            raise ApiError(status, result)
        return {"status": status, "body": result, "headers": response_headers, "raw": raw}
    raise RuntimeError("Retry limit reached")


def add_offset(offset, received):
    result = int(offset) + received
    if received <= 0 or result > 2147483647: raise RuntimeError("Cannot advance this int32 offset; reconcile the query")
    return str(result)

def both(left,right):
    return left and right

def items(value):
    if not isinstance(value, list): raise RuntimeError("Expected a JSON array")
    return value

def count(value):
    return len(items(value))

def deep_equal(left,right):
    if type(left) is not type(right): return False
    if isinstance(left,dict): return left.keys()==right.keys() and all(deep_equal(left[k],right[k]) for k in left)
    if isinstance(left,list): return len(left)==len(right) and all(deep_equal(a,b) for a,b in zip(left,right))
    return left==right

def either(left, right):
    if not isinstance(left, bool) or not isinstance(right, bool): raise RuntimeError("Expected Boolean criteria")
    return left or right

def equal(left, right):
    return type(left) is type(right) and left == right

def field(value, name):
    if not isinstance(value, dict) or name not in value: raise RuntimeError("Missing response field: " + name)
    return value[name]

def is_empty(value):
    return count(value) == 0

def is_present(value):
    return value is not None and value != ""

"""Strict private client journal reference; no transport or application dependency."""
from pathlib import Path
import hashlib
import os
import re
import secrets
from urllib.parse import urlsplit

PREAMBLE=b'EXHIBITDAY-GUIDE-JOURNAL 1\n'

class JournalRefusal(RuntimeError):
    pass

def utf8(value):
    if not isinstance(value,str):raise JournalRefusal('Journal fields are exact strings')
    return value.encode('utf-8',errors='strict')

def strings(values):
    raw=bytearray()
    for value in values:
        item=utf8(value);raw.extend(str(len(item)).encode('ascii'));raw.extend(b':');raw.extend(item)
    return bytes(raw)

def read_strings(raw):
    values=[];offset=0
    while offset<len(raw):
        end=raw.find(b':',offset)
        if end<0:raise JournalRefusal('Incomplete journal string length')
        length=raw[offset:end]
        if not re.fullmatch(b'0|[1-9][0-9]*',length):raise JournalRefusal('Noncanonical journal string length')
        size=int(length);offset=end+1
        if size>len(raw)-offset:raise JournalRefusal('Incomplete journal string')
        values.append(raw[offset:offset+size].decode('utf-8',errors='strict'));offset+=size
    return values

def digest(raw):return hashlib.sha256(raw).hexdigest().upper()

def fingerprint(pairs):
    values=[]
    for name,value in sorted(pairs.items()):
        if not re.fullmatch('[A-Za-z0-9_.-]+',name):raise JournalRefusal('Fingerprint field names must be explicit ASCII identifiers')
        if name.lower() in ('api_key','exhibitday_api_key'):raise JournalRefusal('Never fingerprint the API key')
        values.extend((name,value))
    return digest(strings(values))

def frame(values):
    raw=strings(values)
    return str(len(raw)).encode('ascii')+b' '+digest(raw).encode('ascii')+b'\n'+raw+b'\n'

def decode(raw):
    if not raw.startswith(PREAMBLE):raise JournalRefusal('Unknown or incomplete journal version')
    offset=len(PREAMBLE);records=[]
    while offset<len(raw):
        end=raw.find(b'\n',offset)
        if end<0:raise JournalRefusal('Incomplete journal frame header; reconcile before retry')
        match=re.fullmatch(b'(0|[1-9][0-9]*) ([0-9A-F]{64})',raw[offset:end])
        if match is None:raise JournalRefusal('Invalid journal frame header')
        size=int(match[1]);offset=end+1
        if size>=len(raw)-offset:raise JournalRefusal('Incomplete journal frame; reconcile before retry')
        payload=raw[offset:offset+size];offset+=size
        if raw[offset:offset+1]!=b'\n' or digest(payload).encode('ascii')!=match[2]:raise JournalRefusal('Journal integrity check failed; reconcile before retry')
        records.append(read_strings(payload));offset+=1
    return records

class Journal:
    def __init__(self,path,base,workspace,slug,job,input_fingerprint,writes,mode="resume"):
        self.path=Path(path);self.lock=Path(str(self.path)+'.lock');self.fd=None;self.owned=False;self.identity=None;self.tainted=False;self.intents={};self.saved_values={};self.adopted_values={};self.order=[]
        address=urlsplit(base)
        if address.scheme not in ('https','http')or not address.netloc or address.username is not None or address.query or address.fragment or not re.fullmatch('[a-z][a-z0-9-]*',slug):raise JournalRefusal('Use the actual API base and closed guide slug')
        if not job.strip() or not re.fullmatch('[1-9][0-9]*',workspace) or not re.fullmatch('[0-9A-F]{64}',input_fingerprint):raise JournalRefusal('Use an actual workspace, explicit stable job ID and exact input fingerprint')
        if mode not in ("new","resume"):raise JournalRefusal("Choose new or resume for this local job")
        self.allowed={};manifest=[]
        for step,method,route in writes:
            if not re.fullmatch('[a-z][a-z0-9_-]*',step)or step in self.allowed or method not in ('POST','PATCH','DELETE')or not re.fullmatch('/v1/[A-Za-z0-9_/-]+',route)or'//'in route:raise JournalRefusal('Use a closed unique write manifest')
            self.allowed[step]=(method,route);self.order.append(step);manifest.extend((step,method,route))
        if not self.allowed:raise JournalRefusal('Only write workflows need a restart journal')
        self.header=['H','1',base,workspace,slug,job,input_fingerprint,digest(strings(manifest))]
        strings(self.header)
        try:
            self.fd=os.open(self.lock,os.O_WRONLY|os.O_CREAT|os.O_EXCL,0o600);self.owned=True
        except FileExistsError:raise JournalRefusal('This journal is locked; do not run overlapping jobs or steal a stale lock')
        try:
            self.owner=secrets.token_hex(16);self.identity=os.fstat(self.fd)
            if os.write(self.fd,self.owner.encode('ascii'))!=len(self.owner):raise OSError('Incomplete lock identity write')
            os.fsync(self.fd)
            if self.path.is_symlink():raise JournalRefusal('Choose a private regular journal file')
            if mode=="resume" and not self.path.exists():raise JournalRefusal("Journal missing: stop and reconcile lost state before starting a new logical job")
            if mode=="new" and self.path.exists():raise JournalRefusal("A journal already exists; use resume for the same logical job")
            if mode=="new":
                with open(self.path,'xb',buffering=0)as target:
                    target.write(PREAMBLE+frame(self.header));os.fsync(target.fileno())
            records=decode(self.path.read_bytes())
            if not records or records[0]!=self.header:raise JournalRefusal('Journal workspace/base/guide/job/input binding differs')
            for record in records[1:]:self.apply(record)
            if any(step not in self.saved_values for step in self.intents):raise JournalRefusal('A saved before-send intent lacks an ACK; stop and reconcile its outcome before retry')
        except BaseException:
            self.close();raise

    def apply(self,record):
        if not record:raise JournalRefusal('Empty journal record')
        if record[0]=='I':
            if len(record)!=6:raise JournalRefusal('Invalid intent shape')
            _,step,method,path,request_fingerprint,key=record
            if not re.fullmatch('[a-z][a-z0-9_-]*',step)or step in self.intents or step in self.adopted_values or self.allowed.get(step)!=(method,path)or not re.fullmatch('[0-9A-F]{64}',request_fingerprint)or any(name not in self.saved_values for name in self.intents):raise JournalRefusal('Invalid, future or repeated journal intent')
            if method=='POST'and not re.fullmatch('[0-9a-f]{32}',key)or method!='POST'and key!='':raise JournalRefusal('Invalid persisted action key')
            self.intents[step]={'method':method,'path':path,'request_fingerprint':request_fingerprint,'idempotency_key':key}
        elif record[0]=='A':
            if len(record)<3:raise JournalRefusal('Invalid ACK shape')
            _,step,count,*pairs=record
            if not re.fullmatch('0|[1-9][0-9]*',count)or len(pairs)!=2*int(count)or step not in self.intents or step in self.saved_values:raise JournalRefusal('ACK without exactly one prior intent')
            names=pairs[::2]
            if names!=sorted(set(names))or any(not re.fullmatch('[a-z][a-z0-9_]*',name)or name in ('api_key','exhibitday_api_key')for name in names):raise JournalRefusal('ACK saved fields must be unique sorted secret-free identifiers')
            self.saved_values[step]=dict(zip(names,pairs[1::2]))
        elif record[0]=='S':
            if len(record)<6:raise JournalRefusal('Invalid read-adoption shape')
            _,step,method,path,read_fingerprint,count,*pairs=record
            completed=set(self.saved_values)|set(self.adopted_values)
            if len(completed)>=len(self.order) or completed!=set(self.order[:len(completed)]) or step!=self.order[len(completed)] or any(name not in self.saved_values for name in self.intents):raise JournalRefusal('Adopt only the exact next setup action without any pending intent')
            target=self.allowed.get(step)
            expected='/v1/events/info'if (target==('POST','/v1/events') or step=='update_event' and target==('PATCH','/v1/events'))else '/v1/tasks/sections/info'if target==('POST','/v1/tasks/sections')else None
            if method!='GET' or expected is None or path!=expected:raise JournalRefusal('Adoption requires the exact source-bound single Event or section read')
            if not re.fullmatch('0|[1-9][0-9]*',count)or len(pairs)!=2*int(count):raise JournalRefusal('Invalid read-adoption field count')
            names=pairs[::2];fields=['id','integration_metadata_field_1']if expected=='/v1/events/info'else ['event_id','id','name']
            if names!=fields:raise JournalRefusal('Read-adoption fields must match the exact source tuple')
            saved=dict(zip(names,pairs[1::2]))
            for name in ('id','event_id'):
                if name in saved and (not re.fullmatch('[1-9][0-9]*',saved[name])or int(saved[name])>9223372036854775807):raise JournalRefusal('Read-adoption IDs must be exact positive Int64 strings')
            if any(saved[name]==''for name in fields if name not in ('id','event_id'))or read_fingerprint!=fingerprint(saved):raise JournalRefusal('Read-adoption material must be complete and fingerprint-bound')
            self.adopted_values[step]=saved
        else:raise JournalRefusal('Unknown journal transition')

    def append(self,record):
        # The reader commits state only after complete length/digest recognition.
        # A torn append is retained and refused, never silently truncated.
        self.require_active();raw=frame(record)
        try:
            with open(self.path,'ab',buffering=0)as target:
                view=memoryview(raw)
                while view:
                    written=target.write(view)
                    if not written:raise OSError('Journal write did not advance')
                    view=view[written:]
                os.fsync(target.fileno())
        except BaseException:
            self.tainted=True;raise

    def require_active(self):
        if not self.owned or self.fd is None or self.identity is None or self.tainted:raise JournalRefusal('The journal scope is closed or its IO outcome needs reconciliation')
        current=self.lock.stat(follow_symlinks=False)
        if current.st_dev!=self.identity.st_dev or current.st_ino!=self.identity.st_ino or self.lock.read_text(encoding='ascii')!=self.owner:raise JournalRefusal('The journal lock was replaced; stop without deleting it')
    def acknowledged(self,step):
        self.require_active();return step in self.saved_values
    def saved(self,step):
        self.require_active()
        if step not in self.saved_values:raise JournalRefusal('No acknowledged state exists for this step')
        return dict(self.saved_values[step])
    def completed(self,step):
        self.require_active();return step in self.saved_values or step in self.adopted_values
    def recorded(self,step):
        self.require_active()
        if step in self.saved_values:return dict(self.saved_values[step])
        if step in self.adopted_values:return dict(self.adopted_values[step])
        raise JournalRefusal('No completed write or read-adoption exists')
    def adopted(self,step):
        self.require_active();return step in self.adopted_values
    def adopt(self,step,source_method,source_path,saved):
        self.require_active()
        record=['S',step,source_method,source_path,fingerprint(saved),str(len(saved))]
        for name,value in sorted(saved.items()):record.extend((name,value))
        old={name:dict(value)for name,value in self.adopted_values.items()}
        try:self.apply(record);strings(record)
        finally:self.adopted_values=old
        self.append(record);self.apply(record)
    def begin(self,step,method,path,request_fingerprint):
        self.require_active()
        if step in self.intents:raise JournalRefusal('Never blindly repeat an existing action intent')
        key=secrets.token_hex(16)if method=='POST'else''
        record=['I',step,method,path,request_fingerprint,key]
        # Validate on an isolated state before touching the file.
        old=dict(self.intents)
        try:self.apply(record)
        finally:self.intents=old
        self.append(record);self.apply(record)
        return dict(self.intents[step])
    def acknowledge(self,step,saved):
        self.require_active()
        record=['A',step,str(len(saved))]
        for name,value in sorted(saved.items()):record.extend((name,value))
        old={name:dict(value)for name,value in self.saved_values.items()}
        try:self.apply(record);strings(record)
        finally:self.saved_values=old
        self.append(record);self.apply(record)
    def close(self):
        if self.owned:
            if self.tainted:
                os.close(self.fd);self.fd=None;self.owned=False
                return # Retain this lock after failed journal IO; manual reconciliation is required.
            try:self.require_active()
            except BaseException:
                os.close(self.fd);self.fd=None;self.owned=False;raise
            os.close(self.fd);self.fd=None;self.owned=False
            self.lock.unlink()
    def __enter__(self):return self
    def __exit__(self,*args):self.close()

def journal_values(value):
    if not isinstance(value, dict) or any(not isinstance(k, str) or not isinstance(v, str) for k,v in value.items()):
        raise JournalRefusal('Saved/fingerprint values must be exact string fields')
    return dict(value)

def journal_acknowledge(job, step, saved):
    job.acknowledge(step,journal_values(saved))

def journal_acknowledged(job, step):
    return job.acknowledged(step)

def journal_adopt(job,step,method,path,saved):job.adopt(step,method,path,journal_values(saved))

def journal_begin(job, step, method, path, request_fingerprint):
    return job.begin(step,method,path,request_fingerprint)

def journal_completed(job,step):return job.completed(step)

def journal_fingerprint(value):
    return fingerprint(journal_values(value))

def journal_recorded(job,step):return job.recorded(step)

def not_value(value):
    if not isinstance(value, bool): raise RuntimeError("Expected a Boolean")
    return not value

def open_journal(path, base, workspace, slug, job, input_fingerprint, writes, mode):
    return Journal(path,base,workspace,slug,job,input_fingerprint,writes,mode)

def optional(name, fallback):
    value = os.environ.get(name)
    return fallback if value is None or value == "" else value

def page_size(value):
    if not re.fullmatch(r"[1-9][0-9]*", value) or int(value) > 2147483647: raise RuntimeError("Page size must be a positive int32")
    return value

def parse_json(value):
    import math
    def pairs(values):
        result={}
        for key,item in values:
            if key in result:raise ValueError('Duplicate JSON input property')
            result[key]=item
        return result
    def number(value):
        result=float(value)
        if not math.isfinite(result):raise ValueError('Use finite JSON numbers')
        return result
    def invalid(value):raise ValueError('Use standard JSON values')
    return json.loads(value,object_pairs_hook=pairs,parse_float=number,parse_constant=invalid)

def positive_id(value):
    if not re.fullmatch(r"[1-9][0-9]*", value) or int(value) > 9223372036854775807: raise RuntimeError("Use a positive record ID")
    return value

def print_value(value):
    print(value if isinstance(value, str) else json.dumps(value, ensure_ascii=False))

def require_condition(value, message):
    if value is not True: raise RuntimeError(message)

def required(name):
    value = os.environ.get(name)
    if value is None or not value.strip(): raise RuntimeError("Set " + name)
    return value

def response_status(value):
    return str(value["status"])

def single(value):
    rows=items(value)
    if len(rows)!=1: raise RuntimeError('Expected exactly one selected record')
    return rows[0]

def text(value):
    if value is None: return ""
    if isinstance(value, str): return value
    if isinstance(value, bool): return "true" if value else "false"
    if isinstance(value, int): return str(value)
    raise RuntimeError("Expected a scalar response value")

def validate_crm_event_inputs(key, name, start, end):
    from datetime import date
    spaces = '\u0009\u000A\u000B\u000C\u000D\u0020\u0085\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000'
    for value, label, limit in ((name, 'EXHIBITDAY_EVENT_NAME', 500), (key, 'EXHIBITDAY_EXTERNAL_EVENT_KEY', 3000)):
        utf8(value)
        if not value or value != value.strip(spaces):
            raise JournalRefusal('Remove whitespace at the start or end of ' + label)
        if len(value.encode('utf-16-le')) // 2 > limit:
            raise JournalRefusal(label + ' exceeds ' + str(limit) + ' UTF-16 code units')
    if any(ch in name for ch in '<>\r\n') or name.lower() == 'null':
        raise JournalRefusal('Use plain, single-line EXHIBITDAY_EVENT_NAME text other than null')
    for value, label in ((start, 'EXHIBITDAY_START_DATE'), (end, 'EXHIBITDAY_END_DATE')):
        try:
            valid = re.fullmatch(r'[0-9]{4}-[0-9]{2}-[0-9]{2}', value) and date.fromisoformat(value).year >= 1753
        except ValueError:
            valid = False
        if not valid:
            raise JournalRefusal(label + ' must be a calendar date in YYYY-MM-DD on or after 1753-01-01')
    if end < start:
        raise JournalRefusal('EXHIBITDAY_END_DATE must be on or after EXHIBITDAY_START_DATE')


def main():
    external_event_key = required("EXHIBITDAY_EXTERNAL_EVENT_KEY")
    desired_event_name = required("EXHIBITDAY_EVENT_NAME")
    desired_start_date = required("EXHIBITDAY_START_DATE")
    desired_end_date = required("EXHIBITDAY_END_DATE")
    desired_dates_json = required("EXHIBITDAY_EXHIBIT_DATES_JSON")
    desired_section_name = optional("EXHIBITDAY_TASK_SECTION_NAME", "Pre-event planning")
    setup_page_size = page_size(optional("EXHIBITDAY_PAGE_SIZE", "100"))
    desired_setup_dates = items(parse_json(desired_dates_json))
    validate_crm_event_inputs(external_event_key, desired_event_name, desired_start_date, desired_end_date)
    journal_path = required("EXHIBITDAY_JOURNAL")
    stable_job_id = required("EXHIBITDAY_JOB_ID")
    job_mode = optional("EXHIBITDAY_JOB_MODE", "resume")
    setup_workspace_response = call("workspace_binding", {}, None, None)
    require_condition(equal(response_status(setup_workspace_response), "200"), "Expected the endpoint's documented HTTP200 response; do not infer an acknowledgement from another status.")
    setup_workspace = setup_workspace_response["body"]
    owned_workspace_id = positive_id(text(field(setup_workspace, "id")))
    setup_input_fingerprint = journal_fingerprint({"workflow_contract_sha256": "19097A09AE2D22C1AF56F5D4FBD9B72F524E5EC195434BC315834CC8C2417C32", "external_event_key": external_event_key, "name": desired_event_name, "start_date": desired_start_date, "end_date": desired_end_date, "section_name": desired_section_name, "dates": desired_dates_json})
    setup_job = open_journal(journal_path, "https://api.exhibitday.com/v1", owned_workspace_id, "event-setup-crm", stable_job_id, setup_input_fingerprint, [["create_event", "POST", "/v1/events"], ["update_event", "PATCH", "/v1/events"], ["create_section", "POST", "/v1/tasks/sections"], ["save_dates", "PATCH", "/v1/events/dates"]], job_mode)
    try:
        setup_event_id = ""
        setup_section_id = ""
        recorded_section_name = desired_section_name
        if journal_completed(setup_job, "create_event"):
            recorded_event = journal_recorded(setup_job, "create_event")
            setup_event_id = positive_id(text(field(recorded_event, "id")))
            require_condition(equal(text(field(recorded_event, "integration_metadata_field_1")), external_event_key), "The journal's completed Event differs from this external key.")
        else:
            event_search_offset = "0"
            event_search_query = {"filter_by_integration_metadata_field_1": external_event_key, "$limit": setup_page_size}
            while True:
                event_search_query["$offset"] = event_search_offset
                event_search_response = call("find_existing", event_search_query, None, None)
                require_condition(equal(response_status(event_search_response), "200"), "Expected the endpoint's documented HTTP200 response; do not infer an acknowledgement from another status.")
                event_search_page = event_search_response["body"]
                event_search_rows = items(field(event_search_page, "list_data"))
                require_condition(equal(text(field(event_search_page, "records_found")), text(count(event_search_rows))), "records_found differs from this complete page's rows.")
                require_condition(is_present(text(field(event_search_page, "total_records"))), "The search wrapper needs total_records.")
                require_condition(either(equal(field(event_search_page, "has_more"), True), equal(field(event_search_page, "has_more"), False)), "Expected a Boolean has_more value.")
                for event_search_row in items(event_search_rows):
                    if equal(text(field(event_search_row, "integration_metadata_field_1")), external_event_key):
                        event_search_candidate_id = positive_id(text(field(event_search_row, "id")))
                        if is_present(setup_event_id):
                            require_condition(equal(setup_event_id, event_search_candidate_id), "More than one matching record exists. Reconcile the ambiguity instead of selecting one or creating another.")
                        setup_event_id = event_search_candidate_id
                if equal(field(event_search_page, "has_more"), False):
                    break
                require_condition(not_value(is_empty(event_search_rows)), "An empty search page has has_more=true. Stop and reconcile the search.")
                event_search_offset = add_offset(event_search_offset, count(event_search_rows))
            if not_value(is_present(setup_event_id)):
                event_write_fingerprint = journal_fingerprint({"name": desired_event_name, "start_date": desired_start_date, "end_date": desired_end_date, "integration_metadata_field_1": external_event_key})
                event_intent = journal_begin(setup_job, "create_event", "POST", "/v1/events", event_write_fingerprint)
                event_create_response = call("create_event", {}, {"name": desired_event_name, "start_date": desired_start_date, "end_date": desired_end_date, "integration_metadata_field_1": external_event_key}, text(field(event_intent, "idempotency_key")))
                require_condition(equal(response_status(event_create_response), "200"), "Expected the endpoint's documented HTTP200 response; do not infer an acknowledgement from another status.")
                created_event = event_create_response["body"]
                setup_event_id = positive_id(text(field(created_event, "id")))
                require_condition(equal(text(field(created_event, "integration_metadata_field_1")), external_event_key), "The created Event's external key differs; preserve the pending intent and reconcile.")
                require_condition(both(is_present(text(field(created_event, "name"))), both(is_present(text(field(created_event, "start_date"))), is_present(text(field(created_event, "end_date"))))), "The Event acknowledgement omitted its saved name or main dates.")
                journal_acknowledge(setup_job, "create_event", {"id": setup_event_id, "integration_metadata_field_1": external_event_key})
        event_confirmation_response = call("confirm_event", {"id": setup_event_id, "$include_record_revision": "true"}, None, None)
        require_condition(equal(response_status(event_confirmation_response), "200"), "Expected the endpoint's documented HTTP200 response; do not infer an acknowledgement from another status.")
        confirmed_setup_event = event_confirmation_response["body"]
        require_condition(both(equal(text(field(confirmed_setup_event, "id")), setup_event_id), equal(text(field(confirmed_setup_event, "integration_metadata_field_1")), external_event_key)), "The captured Event is missing or rebound; stop instead of searching for or creating a replacement.")
        if not_value(journal_completed(setup_job, "create_event")):
            journal_adopt(setup_job, "create_event", "GET", "/v1/events/info", {"id": text(field(confirmed_setup_event, "id")), "integration_metadata_field_1": text(field(confirmed_setup_event, "integration_metadata_field_1"))})
        setup_event_revision = text(field(confirmed_setup_event, "record_revision"))
        require_condition(is_present(setup_event_revision), "Read the selected Event with its revision before comparing or updating it.")
        require_condition(both(both(is_present(text(field(confirmed_setup_event, "name"))), is_present(text(field(confirmed_setup_event, "start_date")))), is_present(text(field(confirmed_setup_event, "end_date")))), "The selected Event must return its current name, start date and end date.")
        if journal_completed(setup_job, "update_event"):
            recorded_event_update = journal_recorded(setup_job, "update_event")
            require_condition(both(equal(text(field(recorded_event_update, "id")), setup_event_id), equal(text(field(recorded_event_update, "integration_metadata_field_1")), external_event_key)), "The recorded Event update has a different identity. Stop and reconcile.")
            require_condition(both(both(equal(text(field(confirmed_setup_event, "name")), desired_event_name), equal(text(field(confirmed_setup_event, "start_date")), desired_start_date)), equal(text(field(confirmed_setup_event, "end_date")), desired_end_date)), "The Event name or main dates changed after this job checked them. Review the current Event before writing again.")
        else:
            if both(both(equal(text(field(confirmed_setup_event, "name")), desired_event_name), equal(text(field(confirmed_setup_event, "start_date")), desired_start_date)), equal(text(field(confirmed_setup_event, "end_date")), desired_end_date)):
                journal_adopt(setup_job, "update_event", "GET", "/v1/events/info", {"id": setup_event_id, "integration_metadata_field_1": external_event_key})
            else:
                require_condition(not_value(journal_acknowledged(setup_job, "create_event")), "The Event created by this job differs from the requested values. Inspect the saved Event before starting another update.")
                event_update_body = {"id": setup_event_id, "expected_revision": setup_event_revision}
                if not_value(equal(text(field(confirmed_setup_event, "name")), desired_event_name)):
                    event_update_body["name"] = desired_event_name
                if not_value(equal(text(field(confirmed_setup_event, "start_date")), desired_start_date)):
                    event_update_body["start_date"] = desired_start_date
                if not_value(equal(text(field(confirmed_setup_event, "end_date")), desired_end_date)):
                    event_update_body["end_date"] = desired_end_date
                event_update_fingerprint = journal_fingerprint(event_update_body)
                journal_begin(setup_job, "update_event", "PATCH", "/v1/events", event_update_fingerprint)
                event_update_response = call("update_event", {}, event_update_body, None)
                require_condition(equal(response_status(event_update_response), "200"), "Expected the endpoint's documented HTTP200 response; do not infer an acknowledgement from another status.")
                event_update_ack = event_update_response["body"]
                event_updated_revision = text(field(event_update_ack, "record_revision"))
                require_condition(is_present(event_updated_revision), "The conditional Event update needs its returned revision. Reconcile the pending request before continuing.")
                journal_acknowledge(setup_job, "update_event", {"id": setup_event_id, "integration_metadata_field_1": external_event_key, "record_revision": event_updated_revision})
        event_update_verify_response = call("verify_event_update", {"id": setup_event_id}, None, None)
        require_condition(equal(response_status(event_update_verify_response), "200"), "Expected the endpoint's documented HTTP200 response; do not infer an acknowledgement from another status.")
        verified_setup_event = event_update_verify_response["body"]
        require_condition(both(both(equal(text(field(verified_setup_event, "id")), setup_event_id), equal(text(field(verified_setup_event, "integration_metadata_field_1")), external_event_key)), both(both(equal(text(field(verified_setup_event, "name")), desired_event_name), equal(text(field(verified_setup_event, "start_date")), desired_start_date)), equal(text(field(verified_setup_event, "end_date")), desired_end_date))), "The Event's current identity, name or main dates differ. Inspect the Event before continuing with setup.")
        if journal_completed(setup_job, "create_section"):
            recorded_section = journal_recorded(setup_job, "create_section")
            setup_section_id = positive_id(text(field(recorded_section, "id")))
            require_condition(equal(text(field(recorded_section, "event_id")), setup_event_id), "The recorded Task Section belongs to a different Event.")
            recorded_section_name = text(field(recorded_section, "name"))
        else:
            section_search_offset = "0"
            section_search_query = {"filter_by_event_id": setup_event_id, "$limit": setup_page_size}
            while True:
                section_search_query["$offset"] = section_search_offset
                section_search_response = call("find_section", section_search_query, None, None)
                require_condition(equal(response_status(section_search_response), "200"), "Expected the endpoint's documented HTTP200 response; do not infer an acknowledgement from another status.")
                section_search_page = section_search_response["body"]
                section_search_rows = items(field(section_search_page, "list_data"))
                require_condition(equal(text(field(section_search_page, "records_found")), text(count(section_search_rows))), "records_found differs from this complete page's rows.")
                require_condition(is_present(text(field(section_search_page, "total_records"))), "The search wrapper needs total_records.")
                require_condition(either(equal(field(section_search_page, "has_more"), True), equal(field(section_search_page, "has_more"), False)), "Expected a Boolean has_more value.")
                for section_search_row in items(section_search_rows):
                    require_condition(equal(text(field(section_search_row, "event_id")), setup_event_id), "A section search row belongs to a different Event; stop before adopting or creating anything.")
                    if equal(text(field(section_search_row, "name")), desired_section_name):
                        section_search_candidate_id = positive_id(text(field(section_search_row, "id")))
                        if is_present(setup_section_id):
                            require_condition(equal(setup_section_id, section_search_candidate_id), "More than one matching record exists. Reconcile the ambiguity instead of selecting one or creating another.")
                        setup_section_id = section_search_candidate_id
                if equal(field(section_search_page, "has_more"), False):
                    break
                require_condition(not_value(is_empty(section_search_rows)), "An empty search page has has_more=true. Stop and reconcile the search.")
                section_search_offset = add_offset(section_search_offset, count(section_search_rows))
            if not_value(is_present(setup_section_id)):
                section_write_fingerprint = journal_fingerprint({"event_id": setup_event_id, "name": desired_section_name})
                section_intent = journal_begin(setup_job, "create_section", "POST", "/v1/tasks/sections", section_write_fingerprint)
                section_create_response = call("create_section", {}, {"event_id": setup_event_id, "name": desired_section_name}, text(field(section_intent, "idempotency_key")))
                require_condition(equal(response_status(section_create_response), "200"), "Expected the endpoint's documented HTTP200 response; do not infer an acknowledgement from another status.")
                created_section = section_create_response["body"]
                setup_section_id = positive_id(text(field(created_section, "id")))
                require_condition(equal(text(field(created_section, "event_id")), setup_event_id), "The created Task Section belongs to a different Event; preserve the pending intent.")
                recorded_section_name = text(field(created_section, "name"))
                require_condition(is_present(recorded_section_name), "The Task Section acknowledgement needs its actual saved name.")
                journal_acknowledge(setup_job, "create_section", {"id": setup_section_id, "event_id": setup_event_id, "name": recorded_section_name})
        section_confirmation_response = call("confirm_section", {"id": setup_section_id}, None, None)
        require_condition(equal(response_status(section_confirmation_response), "200"), "Expected the endpoint's documented HTTP200 response; do not infer an acknowledgement from another status.")
        confirmed_setup_section = section_confirmation_response["body"]
        require_condition(both(equal(text(field(confirmed_setup_section, "id")), setup_section_id), both(equal(text(field(confirmed_setup_section, "event_id")), setup_event_id), equal(text(field(confirmed_setup_section, "name")), recorded_section_name))), "The captured Task Section is missing, renamed or rebound; stop instead of creating a replacement.")
        if not_value(journal_completed(setup_job, "create_section")):
            journal_adopt(setup_job, "create_section", "GET", "/v1/tasks/sections/info", {"event_id": text(field(confirmed_setup_section, "event_id")), "id": text(field(confirmed_setup_section, "id")), "name": text(field(confirmed_setup_section, "name"))})
        setup_dates_response = call("read_dates", {"event_id": setup_event_id, "filter_by_date_type_id": "1", "$include_record_revision": "true"}, None, None)
        require_condition(equal(response_status(setup_dates_response), "200"), "Expected the endpoint's documented HTTP200 response; do not infer an acknowledgement from another status.")
        setup_dates_page = setup_dates_response["body"]
        require_condition(both(equal(text(field(setup_dates_page, "records_found")), "1"), both(equal(text(field(setup_dates_page, "total_records")), "1"), equal(field(setup_dates_page, "has_more"), False))), "Expected one complete selected Dates group, without another page.")
        setup_dates_group = single(field(setup_dates_page, "list_data"))
        require_condition(both(equal(text(field(setup_dates_group, "event_id")), setup_event_id), equal(text(field(setup_dates_group, "date_type_id")), "1")), "The Dates group belongs to another Event or type.")
        setup_dates_revision = text(field(setup_dates_group, "record_revision"))
        require_condition(is_present(setup_dates_revision), "Read the actual selected group revision before replacing it.")
        if journal_completed(setup_job, "save_dates"):
            recorded_dates = journal_recorded(setup_job, "save_dates")
            require_condition(both(equal(text(field(recorded_dates, "event_id")), setup_event_id), equal(text(field(recorded_dates, "date_type_id")), "1")), "The recorded Dates acknowledgement belongs to another Event or group.")
        else:
            setup_dates_fingerprint = journal_fingerprint({"event_id": setup_event_id, "date_type_id": "1", "dates": desired_dates_json, "expected_revision": setup_dates_revision})
            journal_begin(setup_job, "save_dates", "PATCH", "/v1/events/dates", setup_dates_fingerprint)
            setup_dates_save_response = call("save_dates", {}, {"event_id": setup_event_id, "date_type_id": "1", "dates": desired_setup_dates, "expected_revision": setup_dates_revision}, None)
            require_condition(equal(response_status(setup_dates_save_response), "200"), "Expected the endpoint's documented HTTP200 response; do not infer an acknowledgement from another status.")
            setup_dates_ack = setup_dates_save_response["body"]
            setup_dates_saved_revision = text(field(setup_dates_ack, "record_revision"))
            require_condition(is_present(setup_dates_saved_revision), "The checked Dates save needs its actual returned revision.")
            journal_acknowledge(setup_job, "save_dates", {"event_id": setup_event_id, "date_type_id": "1", "record_revision": setup_dates_saved_revision})
        setup_dates_verify_response = call("verify_dates", {"event_id": setup_event_id, "filter_by_date_type_id": "1"}, None, None)
        require_condition(equal(response_status(setup_dates_verify_response), "200"), "Expected the endpoint's documented HTTP200 response; do not infer an acknowledgement from another status.")
        setup_dates_verify_page = setup_dates_verify_response["body"]
        require_condition(both(equal(text(field(setup_dates_verify_page, "records_found")), "1"), both(equal(text(field(setup_dates_verify_page, "total_records")), "1"), equal(field(setup_dates_verify_page, "has_more"), False))), "Expected one complete selected Dates group, without another page.")
        setup_dates_verify_group = single(field(setup_dates_verify_page, "list_data"))
        require_condition(both(equal(text(field(setup_dates_verify_group, "event_id")), setup_event_id), equal(text(field(setup_dates_verify_group, "date_type_id")), "1")), "The Dates group belongs to another Event or type.")
        require_condition(deep_equal(field(setup_dates_verify_group, "dates"), desired_setup_dates), "The saved normalized Dates list differs from the supplied canonical list. Inspect it; do not automatically restore or repeat the update.")
        setup_event_readback_response = call("event_readback", {"id": setup_event_id}, None, None)
        require_condition(equal(response_status(setup_event_readback_response), "200"), "Expected the endpoint's documented HTTP200 response; do not infer an acknowledgement from another status.")
        setup_event_readback = setup_event_readback_response["body"]
        require_condition(both(equal(text(field(setup_event_readback, "id")), setup_event_id), equal(text(field(setup_event_readback, "integration_metadata_field_1")), external_event_key)), "Final Event readback is missing or rebound; earlier steps remain saved.")
        require_condition(both(both(equal(text(field(setup_event_readback, "name")), desired_event_name), equal(text(field(setup_event_readback, "start_date")), desired_start_date)), equal(text(field(setup_event_readback, "end_date")), desired_end_date)), "The Event name or main dates changed before final readback. Inspect the Event before starting another update.")
        planning_section_present = False
        for setup_event_section in items(items(field(setup_event_readback, "task_sections"))):
            if equal(text(field(setup_event_section, "id")), setup_section_id):
                planning_section_present = True
        require_condition(planning_section_present, "The Event's current Task Sections do not include the recorded section; inspect it rather than creating another.")
        print_value({"event_id": setup_event_id, "task_section_id": setup_section_id, "dates_verified": "true"})
    finally:
        setup_job.close()


if __name__ == "__main__":
    main()

EXHIBITDAY_PY

Example response

{
  "id": 5001,
  "exhibitday_url": "https://www.exhibitday.com/Workspace/Event/98765?eid=5001",
  "name": "Spring Expo 2030",
  "start_date": "2030-01-14",
  "end_date": "2030-01-16",
  "participation_type_id": 1,
  "participation_type": "Committed",
  "format_id": 1,
  "format": "In-Person",
  "star_rating": 0,
  "tags": [
    "International",
    "Field Marketing"
  ],
  "website_url": "",
  "venue_name": "",
  "venue_address": "",
  "venue_location_display_name": "",
  "venue_address_latitude": "",
  "venue_address_longitude": "",
  "booth_size": "",
  "booth_number": "",
  "booth_reservation_status_id": 1,
  "booth_reservation_status": "Need to Reserve",
  "booth_reserve_by_date": "",
  "booth_date_reserved": "",
  "budget_booth_reservation": 0.00,
  "budget_booth_services": 0.00,
  "budget_attendee_registrations": 0.00,
  "budget_travel": 0.00,
  "budget_giveaways": 0.00,
  "budget_shipments": 0.00,
  "budget_event_activities": 0.00,
  "budget_misc_expenses": 0.00,
  "budget_sponsorships": 0.00,
  "total_sum_event_budgets": 0.00,
  "booth_reservation_cost": {
    "amount": 125.50,
    "cost_center_breakdown": [
      {
        "cost_center_id": 34567,
        "cost_center": "Marketing",
        "charge": 75.50
      },
      {
        "cost_center_id": 34568,
        "cost_center": "Operations",
        "charge": 50.00
      }
    ]
  },
  "cost_booth_reservation": 125.50,
  "booth_reservation_payment_status_id": 0,
  "booth_reservation_payment_status": "",
  "booth_reservation_payment_due_date": null,
  "booth_reservation_next_payment_due_date": null,
  "booth_reservation_payment_notes": null,
  "booth_reservation_invoice_attachment": {
    "id": 175001,
    "filename": "booth-reservation-invoice.pdf",
    "attachment_created_timestamp": "2027-01-30T12:00:00Z"
  },
  "cost_booth_services": 0.00,
  "cost_attendee_registrations": 0.00,
  "cost_travel_reservations": 0.00,
  "cost_giveaways": 0.00,
  "cost_shipments": 0.00,
  "cost_event_activities": 0.00,
  "cost_misc_expenses": 100.50,
  "cost_sponsorships": 0.00,
  "total_sum_event_costs": 226.00,
  "event_notes": "",
  "booth_notes": "",
  "budget_notes": "",
  "roi_notes": "",
  "roi_num_leads": 0,
  "roi_num_impressions_booth": 0,
  "roi_num_impressions_sponsorships": 0,
  "roi_num_impressions_media": 0,
  "roi_num_meetings_existing_customers": 0,
  "roi_num_meetings_new_customers": 0,
  "roi_amount_actual_sales": 0.00,
  "roi_amount_potential_sales": 0.00,
  "roo_score": null,
  "event_created_timestamp": "2029-12-01T17:00:00Z",
  "event_last_update_timestamp": "2030-01-02T17:00:00Z",
  "event_created_by": null,
  "custom_fields": [
    {
      "label": "Integration status",
      "value": "Ready",
      "notes": "",
      "field_name": "custom_67890",
      "field_type": "Text (Single-line)",
      "field_event_tab": "Info"
    },
    {
      "label": "Setup instructions",
      "value": "Place the display beside the entrance.",
      "notes": "",
      "field_name": "custom_67891",
      "field_type": "Text (Single-line)",
      "field_event_tab": "Booth"
    }
  ],
  "task_sections": [
    {
      "id": 6001,
      "name": "Pre-event planning",
      "display_rank": 0
    },
    {
      "id": 6002,
      "name": "Onsite follow-up",
      "display_rank": 1
    }
  ],
  "tasks": [
    {
      "id": 7002,
      "exhibitday_url": "https://www.exhibitday.com/Workspace/TaskView/98765?tid=7002",
      "event_task_section_id": 6001,
      "event_task_section": "Pre-event planning",
      "display_rank": 1,
      "name": "Confirm booth setup",
      "due_date": "2030-01-12",
      "assignee": {
        "id": "11111111-2222-4333-8444-555555555555",
        "first_name": "Jane",
        "last_name": "Smith",
        "display_name": "Jane Smith",
        "email": "jane@example.invalid",
        "type": "user",
        "workspace_role": "team_member",
        "is_active": true
      },
      "is_completed": false,
      "task_completed_timestamp": null,
      "task_created_timestamp": "2029-12-01T17:01:00Z",
      "task_last_update_timestamp": "2029-12-01T17:01:00Z"
    },
    {
      "id": 7003,
      "exhibitday_url": "https://www.exhibitday.com/Workspace/TaskView/98765?tid=7003",
      "event_task_section_id": 6002,
      "event_task_section": "Onsite follow-up",
      "display_rank": 2,
      "name": "Prepare the staff schedule",
      "due_date": "2030-01-13",
      "assignee": {
        "id": "66666666-7777-4888-8999-aaaaaaaaaaaa",
        "first_name": "Alex",
        "last_name": "Jordan",
        "display_name": "Alex Jordan",
        "email": "alex@example.invalid",
        "type": "user",
        "workspace_role": "team_member",
        "is_active": true
      },
      "is_completed": false,
      "task_completed_timestamp": null,
      "task_created_timestamp": "2029-12-01T17:02:00Z",
      "task_last_update_timestamp": "2029-12-01T17:02:00Z"
    }
  ],
  "misc_expenses_credits": [
    {
      "id": 8002,
      "exhibitday_url": "https://www.exhibitday.com/Workspace/Event/98765?eid=5001&riType=8&riSub=0&riId=8002",
      "description": "Conference meals",
      "is_credit": false,
      "cost": {
        "amount": 125.50,
        "cost_center_breakdown": [
          {
            "cost_center_id": 34567,
            "cost_center": "Marketing",
            "charge": 75.50
          },
          {
            "cost_center_id": 34568,
            "cost_center": "Operations",
            "charge": 50.00
          }
        ]
      },
      "notes": "",
      "payment_due_date": null,
      "payment_status": {
        "id": 0,
        "name": "Not Specified"
      },
      "next_payment_due_date": null,
      "next_partial_payment_due_date": null,
      "payment_notes": null,
      "invoice_attachment": {
        "id": 678002,
        "filename": "expense-invoice.pdf",
        "attachment_created_timestamp": "2027-01-30T12:00:00Z"
      },
      "event_misc_expense_credit_created_timestamp": "2029-12-01T17:00:00Z",
      "event_misc_expense_credit_last_update_timestamp": "2029-12-01T17:00:00Z"
    },
    {
      "id": 8003,
      "exhibitday_url": "https://www.exhibitday.com/Workspace/Event/98765?eid=5001&riType=8&riSub=0&riId=8003",
      "description": "Supplier refund",
      "is_credit": true,
      "cost": {
        "amount": -25.00,
        "cost_center_breakdown": [
          {
            "cost_center_id": 34567,
            "cost_center": "Marketing",
            "charge": -15.00
          },
          {
            "cost_center_id": 34568,
            "cost_center": "Operations",
            "charge": -10.00
          }
        ]
      },
      "notes": "",
      "payment_due_date": null,
      "payment_status": {
        "id": 0,
        "name": "Not Specified"
      },
      "next_payment_due_date": null,
      "next_partial_payment_due_date": null,
      "payment_notes": null,
      "invoice_attachment": {
        "id": 678003,
        "filename": "expense-invoice.pdf",
        "attachment_created_timestamp": "2027-01-30T12:00:00Z"
      },
      "event_misc_expense_credit_created_timestamp": "2029-12-01T17:00:00Z",
      "event_misc_expense_credit_last_update_timestamp": "2029-12-01T17:00:00Z"
    }
  ],
  "integration_metadata_field_1": "crm:event:spring-expo-2030",
  "integration_metadata_field_2": null,
  "integration_metadata_field_3": null,
  "integration_metadata_field_4": null,
  "integration_metadata_field_5": null
}
Note: Confirmed Event planning setup. The final Event read confirms the saved external key and planning section. The separate Dates read has already checked the complete Exhibit Hall schedule.

Things to keep in mind

  • Use one CRM key per Event. ExhibitDay allows the same key on more than one Event.
  • If two runs could create the same Event, run them one at a time.
  • If the search finds more than one match, the program stops so you can check.
  • Enter Exhibit Hall times in the Event's local time. ExhibitDay saves the time-zone label you send and keeps the times as entered.
  • The Event and its Exhibit Hall dates are protected from overwrites separately.

If a run stops

  • Each step saves on its own, so a stopped run may have saved some steps.
  • Keep the journal private. It records what the program tried to save and which saves it confirmed.
  • To continue a run with no unresolved save, use EXHIBITDAY_JOB_MODE=resume with the same job ID, journal path and inputs.
  • If a save stopped with a conflict, a lost response or a missing revision, check what was saved in ExhibitDay before running the program again.
  • If you still need changes after checking the old run, set EXHIBITDAY_JOB_MODE=new with a new job ID and journal path.
  • Start a new job when your CRM sends new values.
  • Run only one copy per journal.
  • If a crash leaves a .lock file, make sure no copy using that journal is running or can start. Then remove the lock file and keep the journal.