# Fix Segment webhook destination failing with 400 bad request

## TL;DR
A 400 from a Segment webhook destination means the payload Segment sends does not match what the destination expects. Check the destination's required fields and fix your Segment mapping or payload shape. Segment delivered fine; the destination rejected the content.

## The error
```text
Segment webhook destination failed
HTTP 400 Bad Request from destination endpoint
```

## Use this skill
Agent? Search Vectle for this error:
```bash
curl -s "https://vectle.com/api/v1/search?q=segment webhook destination failed 400 bad request"
```

## Fix it

### Step 1: Read the destination's error detail

```bash
Open the Segment destination's event delivery log and read the full 400 response body.
```

Expected: You see which field or format the destination rejected.

### Step 2: Compare with the destination's expected schema

```bash
Check the destination docs for required fields on the webhook payload.
```

Expected: You find the mismatch: a missing field, wrong type, or wrong nesting.

### Step 3: Fix the mapping in Segment

```bash
Adjust the Segment destination mapping or the source payload to produce what the destination wants.
```

Expected: A test event carries the corrected shape.

### Step 4: Send a test event

```bash
Trigger a test event through Segment to the destination.
```

Expected: The destination returns 200.

### Step 5: Watch for recurring 400s

```bash
Monitor the delivery log for a day after the fix.
```

Expected: No new 400s; the mapping holds for all event types.

## When this applies

- Segment webhook destinations fail with 400
- Some event types deliver while others 400
- You just changed the payload shape upstream

## When it doesn't

- The destination 401s or 403s (check credentials)
- The destination times out (check reachability)
- Segment itself errors (check the source debugger)

## Compatibility

Segment destinations (webhook type). Destination APIs vary.

## Variant phrasings

### segment destination 400 bad request

Same failure. The destination's response body names the offending field; read it first.

### segment webhook payload rejected

Rejection is about content, not connectivity. Fix the shape, not the network.

### segment mapping 400 destination

Mappings that rename or drop required fields are the usual culprit after edits.

## Why it happens

Segment forwards your events to the destination mostly as-is, shaped by your mapping. When the mapping drops a required field or changes a type, the destination's validation rejects the whole payload with 400. Segment did its job; the contract between your mapping and the destination broke.

## Edge cases

- Different event types have different required fields; test track, identify, and page separately
- A destination API version bump can add required fields overnight; pin or watch their changelog
- 400s on retries of old events are expected if the schema changed; replay only corrected events

## If it still fails

- Reproduce with a test event from the provider dashboard to separate delivery problems from handler bugs.
- Log the raw payload shape, never customer PII, so the next failure is comparable.
- Check the provider status page; delivery outages mimic endpoint bugs.
- Replay a known-good event after the fix to prove the path works, not just that errors stopped.
- If signature failures persist with correct code, rotate the signing secret once; stale secrets cause silent mismatches.

## Prevention

- Return 200 fast and process async on every new webhook receiver.
- Make event handling idempotent from day one; retries are guaranteed.
- Monitor delivery success rates, not just endpoint uptime.
- Keep signing secrets per endpoint and rotate them on a schedule.
- Reconcile critical events against the provider API, not just webhooks.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_pQOoeWlhiFjEzAMDRP0M2g
