> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wede.pt/llms.txt
> Use this file to discover all available pages before exploring further.

# Update a parser

> Change a parser version's name, description, schema or active status, or delete it.

## Authentication

Session token (`Authorization: Bearer <token>`) with the `parsers:write` permission. Tenant roles with it: `company_admin`, `company_tech`, `operational_supervisor`, `corporate_client`.

> [!WARNING]
>
> The integration API key (`x-wede-api-key`) has no `parsers:*` permission. Calls with an API key return `403 forbidden`.

***

## Update a parser

```http theme={null}
PATCH /v1/parsers/{id}
```

**id** `string` *required*

Parser UUID.

**name** `string`

2 to 100 characters.

**description** `string`

Up to 500 characters.

**schema** `object[]`

The complete new list of 1 to 50 [field definitions](/api-reference/parsers/create.md#field-definition). It replaces the stored schema and must respect the field protection rules below.

**is\_active** `boolean`

`true` activates this version and deactivates every other version of the same vertical. `false` deactivates only this version.

Send only the fields you want to change. A body with no fields returns the parser unchanged.

```bash theme={null}
curl -X PATCH https://api.wede.pt/v1/parsers/550e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "is_active": true,
    "schema": [
      { "id": "lg_eid", "name": "event_id", "sms_code": "eid", "type": "string", "required": true, "enabled": true, "section": "core", "max_bytes": 12 },
      { "id": "lg_ts", "name": "timestamp", "sms_code": "ts", "type": "timestamp", "required": true, "enabled": true, "section": "core", "max_bytes": 14 },
      { "id": "lg_ref", "name": "parcel_ref", "sms_code": "ref", "type": "string", "required": false, "enabled": true, "section": "custom", "max_bytes": 16, "custom": true }
    ]
  }'
```

Returns `200` with the updated [parser object](/api-reference/parsers/list.md#the-parser-object).

### Field protection

wede compares the schema you send with the schema it has stored, matching fields by `id`, and rejects the whole update if any rule is broken:

| Field | Cannot be removed | Cannot be disabled (`enabled: false`) | `locked` flag |
| - | - | - | - |
| Integrity core: fields named `event_id` and `timestamp` | Yes | Yes | Cannot be unlocked |
| Locked: fields stored with `locked: true` | Yes | Yes | Only wede can change it |
| Any other field | No | No | Only wede can change it, also on a field you add |

A rejected update returns `403` and changes nothing. wede records it in your audit log.

```json theme={null}
{
  "error": "protected_fields",
  "message": "Update violates field protection rules.",
  "violations": [
    { "field": "event_id", "reason": "integrity_core_cannot_be_disabled" }
  ]
}
```

Possible `reason` values: `integrity_core_cannot_be_removed`, `integrity_core_cannot_be_disabled`, `integrity_core_cannot_be_unlocked`, `locked_field_cannot_be_removed`, `locked_field_cannot_be_disabled`, `lock_flag_change_requires_wede_admin`.

Fields marked `legal: true` are not protected by these rules. They label personal data, and you decide which of them your operation needs: enable, disable or remove them like any other field.

### Errors

| Status | `error` | When |
| - | - | - |
| `400` | `validation_error` | The body does not match the schema. `details` lists the failing fields. |
| `401` | `unauthorized` | Missing, invalid or expired credentials. |
| `403` | `forbidden` | Your role lacks `parsers:write`, or you used an API key. |
| `403` | `protected_fields` | The new schema breaks a field protection rule. |
| `404` | `not_found` | No parser with this `id` in your tenant. |
| `500` | `internal_error` | Unexpected server error. |

***

## Delete a parser

```http theme={null}
DELETE /v1/parsers/{id}
```

Deletes one parser version. Other versions of the vertical are not changed.

```bash theme={null}
curl -X DELETE https://api.wede.pt/v1/parsers/550e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN"
```

Returns `204` with no body.

### Errors

| Status | `error` | When |
| - | - | - |
| `401` | `unauthorized` | Missing, invalid or expired credentials. |
| `403` | `forbidden` | Your role lacks `parsers:write`, or you used an API key. |
| `404` | `not_found` | No parser with this `id` in your tenant. |
| `500` | `internal_error` | Unexpected server error. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.