Auto Create User from Ticket-API

Hi guys,

following this ticket:

I did exactly like bernd and try to create a ticket with an unknown user using the guess: way
Unfortunately it doesnt work.

Are there any changes with zammad 4.x that caused it to stop working?
If so, wouldnt make it support it again. Especially when providing Supports-Widget on web I love to not check/create for existing users but let the system do it right away.

Here is my request:

    request_body = {
        "title": f"Form Submission - {form_name}",
        "group": "Users",
        "customer_id": f"guess:{email}",
        "note": "Note",
        "article": {
            "subject": "Anfrage {form_name}",
            "body": f"{}",
            "from": name,
            "to": email,
            "type": "email",
            "internal": False

    headers = {
        "Authorization": f"Token {settings.ZAMMAD_TOKEN}"

    response ='{settings.ZAMMAD_URL}/api/v1/tickets',

I tried with both X-Behalf-of header and without. The ticket is created is created when using x-behalf-of, but then with the existing account instead of the new one that should be created.


Oh yes, please.
We have an own “Create new ticket” form in our application and are jumping through the following hoops to create a ticket:

Check if user exists 
GET /api/v1/users/search?limit=1& X-On-Behalf-Of null

if not exist, create it
POST /api/v1/users X-On-Behalf-Of null

create ticket with the of the new or existing user from above:
POST /api/v1/tickets/ with X-On-Behalf-Of: from above

Would be great to just do it in one shot.
The newly created ticket should belong to the customer (by email).

Initially I would have had expected that X-On-Behalf-Of would work like this, but it fails if the user does not exist yet.

You can simplify this by just

POST /api/v1/users with the


POST /api/v1/tickets/ with X-On-Behalf-Of

This will create a user if non exists and returns an error when a users already exists.
Then just create the ticket with the e-mail

So you can save yourself the first call.

Ok thanks. This saves the first call.
I need to find out how the error looks like. Unfortunately errors are often an HTML page instead of a JSON response. Maybe we decided for the approach with 3 calls, so we have proper JSON everytime, as HTML-error pages also could mean “Service unavailable”, and parsing error message in HTML is not fun :stuck_out_tongue:

This topic was automatically closed after 416 days. New replies are no longer allowed.