# Enable PGP for article via API

**URL:** <https://community.zammad.org/t/enable-pgp-for-article-via-api/18962>\
**Category:** Development\
**Created:** [October 22, 2025, 4:01pm UTC](https://community.zammad.org/t/enable-pgp-for-article-via-api/18962 "2025-10-22T16:01:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![macr](https://community.zammad.org/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@macr](https://community.zammad.org/u/macr)\
**Post date:** [October 22, 2025, 4:01pm UTC](https://community.zammad.org/t/enable-pgp-for-article-via-api/18962/1 "2025-10-22T16:01:23Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![MrGeneration](https://community.zammad.org/user_avatar/community.zammad.org/mrgeneration/32/9260_2.png) [@MrGeneration](https://community.zammad.org/u/MrGeneration)\
**Post date:** [October 22, 2025, 4:38pm UTC](https://community.zammad.org/t/enable-pgp-for-article-via-api/18962/2 "2025-10-22T16:38:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![macr](https://community.zammad.org/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@macr](https://community.zammad.org/u/macr)\
**Post date:** [October 22, 2025, 6:39pm UTC](https://community.zammad.org/t/enable-pgp-for-article-via-api/18962/3 "2025-10-22T18:39:40Z")

</div>

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:

```ruby
'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:

```auto
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!

---

<div class="post-metadata">

**Author:** ![macr](https://community.zammad.org/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@macr](https://community.zammad.org/u/macr)\
**Post date:** [October 22, 2025, 6:48pm UTC](https://community.zammad.org/t/enable-pgp-for-article-via-api/18962/4 "2025-10-22T18:48:48Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![system](https://community.zammad.org/uploads/default/original/1X/5c5afaea2d23f811dbec33cd4edb02fa29d3262f.png) [@system](https://community.zammad.org/u/system)\
**Post date:** [October 29, 2025, 6:49pm UTC](https://community.zammad.org/t/enable-pgp-for-article-via-api/18962/5 "2025-10-29T18:49:12Z")

</div>

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