# Install per-tenant Stripe credentials

`PUT /api/v1/gateway-credentials/stripe`

Requires `gateway.manage`. The key is verified with Stripe before anything is stored: `422 stripe_key_rejected` when Stripe does not accept it, `503 stripe_unavailable` when Stripe cannot be reached. A webhook endpoint for this workspace is then created in the Stripe account (or found and updated) and its signing secret stored; a restricted key that cannot manage webhooks still saves, with `verification.webhook_registered: false`. Sending `webhook_secret` keeps the manual path: nothing is created. Values are AES-256-GCM encrypted at rest. The key’s own mode segment must match `mode`: a `sk_live_…` filed under test would silently make test-mode charges real.

No API key can call this route: it needs a signed-in dashboard user with the right role. A key answers 403.

## Request body

JSON Schema:

```json
{
  "type": "object",
  "properties": {
    "mode": {
      "type": "string",
      "enum": [
        "test",
        "live"
      ]
    },
    "secret_key": {
      "type": "string",
      "example": "sk_test_..."
    },
    "webhook_secret": {
      "type": "string",
      "example": "whsec_..."
    },
    "publishable_key": {
      "type": "string",
      "example": "pk_test_..."
    }
  },
  "required": [
    "mode",
    "secret_key"
  ]
}
```

## Responses

### 200

Masked status for both modes. The submitted secret is never echoed.

JSON Schema:

```json
{
  "type": "object",
  "properties": {
    "data": {
      "type": "object",
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "test",
                  "live"
                ]
              },
              "configured": {
                "type": "boolean"
              },
              "secretKeyHint": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Last 4 characters only."
              },
              "publishableKeyHint": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "hasWebhookSecret": {
                "type": "boolean"
              },
              "account_name": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Stripe account display name from the last successful check."
              },
              "account_id_hint": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Last 4 characters of the Stripe account id."
              },
              "verified_at": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "When Stripe last accepted the key. Null until first checked."
              },
              "checked_at": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "webhook_registered": {
                "type": "boolean",
                "description": "True while the endpoint in the Stripe account was created by GlobalyMint."
              },
              "webhook_reason": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Why not: restricted_key, existing_endpoint, manual, manual_quiet, no_public_url, limit_reached or error."
              },
              "last_event_at": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Last signature-verified inbound Stripe event."
              },
              "last_event_type": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "status": {
                "type": "string",
                "enum": [
                  "connected",
                  "needs_attention",
                  "not_connected"
                ]
              },
              "reason": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "One short sentence when status is needs_attention."
              },
              "reason_code": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "not_verified",
                  "key_rejected",
                  "webhook_missing",
                  "no_events",
                  "webhook_unverified",
                  null
                ]
              }
            },
            "required": [
              "mode",
              "configured",
              "secretKeyHint",
              "publishableKeyHint",
              "hasWebhookSecret",
              "account_name",
              "account_id_hint",
              "verified_at",
              "checked_at",
              "webhook_registered",
              "webhook_reason",
              "last_event_at",
              "last_event_type",
              "status",
              "reason",
              "reason_code"
            ]
          }
        },
        "verification": {
          "type": "object",
          "properties": {
            "mode": {
              "type": "string",
              "enum": [
                "test",
                "live"
              ]
            },
            "account_name": {
              "type": [
                "string",
                "null"
              ]
            },
            "webhook_registered": {
              "type": "boolean"
            },
            "webhook_created": {
              "type": "boolean"
            },
            "webhook_reason": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "mode",
            "account_name",
            "webhook_registered",
            "webhook_created",
            "webhook_reason"
          ]
        },
        "webhook_endpoint": {
          "type": "object",
          "properties": {
            "url": {
              "type": [
                "string",
                "null"
              ],
              "description": "The inbound endpoint for this workspace."
            },
            "events": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Exactly the Stripe events the backend handles."
            }
          },
          "required": [
            "url",
            "events"
          ]
        }
      },
      "required": [
        "items",
        "verification",
        "webhook_endpoint"
      ]
    },
    "_agent": {
      "type": "object",
      "properties": {
        "summary": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "ok"
          ]
        },
        "next_actions": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "warnings": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "summary",
        "status",
        "next_actions",
        "warnings"
      ]
    },
    "api_version": {
      "type": "string",
      "example": "2026-07-01"
    }
  },
  "required": [
    "data",
    "_agent",
    "api_version"
  ]
}
```
