# Call zendesk api from retool without exposing api token

> Internal tools query tickets without embedding subdomain API tokens in queries. For "call zendesk api from retool without exposing api token", store ZENDESK_API_TOKEN in Secret Vault, call https://{{secrets.ZENDESK_SUBDOMAIN}}.zendesk.com/api/v2/tickets.json from a Worker, and let Retool hit only https://realcomposer.com/v1/workspace/call-zendesk-from-retool-securely with an rc_live_ client token.

- Canonical page: https://realcomposer.com/recipes/call-zendesk-from-retool-securely
- Client platform: Retool
- Upstream services: Zendesk
- Category: Security & Secret Vault
- JSON version: https://realcomposer.com/recipes/call-zendesk-from-retool-securely.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=call-zendesk-from-retool-securely&via=agent

## Problem: Why Retool leaks Zendesk credentials

Attackers routinely extract Zendesk secrets from Retool builds. Direct browser calls also expose internal error payloads with hostnames.

- Production Zendesk keys copied from Retool bundles
- Compliance violations after credential leaks
- Attackers replaying vault-grade scopes from a laptop

## Solution steps

1. **Store upstream credentials in Secret Vault**: Create ZENDESK_API_TOKEN vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders.

2. **Target the real upstream URL**: Configure headersTemplate to inject vault secrets, target https://{{secrets.ZENDESK_SUBDOMAIN}}.zendesk.com/api/v2/tickets.json, and Add output mapping fields that mirror the JSON contract your screen already expects.

3. **Query from Retool**: Allowed origins on the token should list every Retool host that calls this URL.

```
// REST resource or JS query
const rows = await fetch('https://realcomposer.com/v1/workspace/call-zendesk-from-retool-securely', {
  headers: { Authorization: 'Bearer rc_live_token' }
}).then(r => r.json());
```

## Pipeline config

Import this config into a RealComposer pipeline. `{{secrets.NAME}}` values are read from the encrypted Secret Vault at request time, so the client never sees them.

```json
{
  "name": "Call zendesk api from retool without exposing api token",
  "method": "GET",
  "cacheTtlSeconds": 0,
  "authMode": "client_token",
  "steps": [
    {
      "stepKey": "zendesk",
      "upstreamUrlTemplate": "https://{{secrets.ZENDESK_SUBDOMAIN}}.zendesk.com/api/v2/tickets.json",
      "httpMethod": "GET",
      "headersTemplate": {
        "Authorization": "Bearer {{secrets.ZENDESK_API_TOKEN}}"
      },
      "timeoutMs": 3000
    }
  ],
  "outputMapping": {
    "version": 1,
    "fields": [
      {
        "targetPath": "ticketId",
        "sourcePath": "tickets.0.id",
        "type": "number",
        "sourceStep": "zendesk"
      },
      {
        "targetPath": "subject",
        "sourcePath": "tickets.0.subject",
        "type": "string",
        "sourceStep": "zendesk"
      },
      {
        "targetPath": "status",
        "sourcePath": "tickets.0.status",
        "type": "string",
        "sourceStep": "zendesk"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X GET "https://realcomposer.com/v1/workspace/call-zendesk-from-retool-securely" \
  -H "Authorization: Bearer rc_live_client_token"
```

## Payload before and after

Raw upstream response:

```json
{
  "requestId": "req_call-zen",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "call-zendesk-from-retool-securely"
  },
  "payload": {
    "id": "sample_id",
    "status": "active",
    "nested": {
      "tags": [
        "demo"
      ],
      "internal": true
    },
    "unused_blob": {
      "foo": "bar",
      "bar": "baz"
    }
  }
}
```

Slimmed RealComposer response:

```json
{
  "ticketId": "sample",
  "subject": "sample",
  "status": "sample"
}
```

## FAQ

### Which Zendesk credential belongs in the vault for this pipeline?

Log request IDs for call-zendesk-from-retool-securely, not raw Zendesk payloads, because upstream bodies may include PII.

### What cache key does RealComposer use?

call-zendesk-from-retool-securely vault headers attach server-side, but Anthropic or OpenAI model and messages must come from the client body.

### Can I restrict which domains call this pipeline?

Upstream steps in call-zendesk-from-retool-securely honor timeoutMs and optional fallback JSON without leaking secrets.
