Enable PGP for article via API

Hi everyone,

I’m trying to figure out how to send PGP encrypted and signed emails when creating a ticket / article via the Zammad API.

In my setup, the default agent setting for outgoing emails is configured to “PGP signed + encrypted.” When I create an email via the UI, those options are automatically checked and everything works as expected — the outgoing message is signed and encrypted.

However, when I create a ticket (and article) via the API on behalf of an agent, the message is sent successfully, but it’s neither encrypted nor signed.

I’ve looked through the API documentation, but I couldn’t find any parameter or option that would allow enabling encryption or signing for the article when it’s created.

Is there a way to enable PGP encryption and signing when creating tickets or articles via the API?
If not, is there perhaps a workaround (e.g., setting specific headers, using a different endpoint, or mimicking the UI behavior somehow)?

Thanks in advance for any pointers!

The easiest way to find out how the UI does it, is to open your developer console and create a test ticket that fits your needs.

You will find a ticket create call with payload. This should help you imho.

That was actually the first thing I tried as well. After replicating the PUT request that the UI sends, i added something like this to the article payload:

'preferences' => {
  'security' => {
    'encryption' => {
      'success' => true
    },
    'type' => "PGP", 
  },
},

In theory, this looks fine — the ticket even shows the encryption checkmark. However, the email isn’t actually delivered; after 1–2 minutes, the ticket shows this error:

Delivery failed: Unable to send email to 'x@x.de': Can't use Channel::Driver::Smtp: #<NoMethodError: undefined method `[]' for nil:NilClass>

So I don’t think this hacky approach is the right way. I’m currently digging through the repo to see if there’s a proper API input for these PGP settings — but it’s a lot of code to navigate when you’re new to it. If I find something before anyone else does, I’ll share it here — and of course, I’d be happy for any hints in the meantime!

Got it — the solution was that I have to sign and encrypt, not just encrypt.
So this example payload worked for me:

$payload = [
    // (...)
    'preferences' => [
        'security' => [
            'encryption' => [
                'success' => true
            ],
            'sign' => [
                'success' => true
            ],
            'type' => "PGP", 
        ],
    ],
];
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.