# Swap primary and fallback keys (/docs/api/access/credentials_swap)

Make the fallback key the primary and the primary the fallback for one provider. Takes effect on the next call.

`POST /v1/credentials/{provider}/swap`

```json
{
  "operationId": "credentials_swap",
  "summary": "Swap primary and fallback keys",
  "description": "Make the fallback key the primary and the primary the fallback for one provider. Takes effect on the next call.",
  "tags": [
    "credentials"
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "parameters": [
    {
      "schema": {
        "type": "string",
        "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
      },
      "required": true,
      "name": "provider",
      "in": "path"
    }
  ],
  "responses": {
    "200": {
      "description": "OK",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "items": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": [
                        "credential"
                      ]
                    },
                    "id": {
                      "type": "string"
                    },
                    "provider": {
                      "type": "string"
                    },
                    "slot": {
                      "type": "string",
                      "enum": [
                        "primary",
                        "fallback"
                      ]
                    },
                    "fields": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "label": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "default": null
                    },
                    "hint": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "default": null
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "healthy",
                        "failing",
                        "unverified"
                      ],
                      "default": "unverified"
                    },
                    "tested_at": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time",
                      "default": null
                    },
                    "test_message": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "default": null
                    },
                    "last_used_at": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time",
                      "default": null
                    },
                    "updated_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "provider",
                    "slot",
                    "fields",
                    "updated_at"
                  ]
                }
              }
            },
            "required": [
              "items"
            ]
          }
        }
      }
    },
    "default": {
      "description": "Error",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "error": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string",
                    "enum": [
                      "invalid_request",
                      "unauthorized",
                      "insufficient_balance",
                      "max_cost_exceeded",
                      "scope_denied",
                      "budget_blocked",
                      "not_found",
                      "idempotency_mismatch",
                      "invalid_meta",
                      "rate_limited",
                      "upstream_error",
                      "response_buffer_limit",
                      "provider_capacity_unavailable",
                      "grid_saturated",
                      "upstream_timeout",
                      "conflict",
                      "internal_error",
                      "account_frozen",
                      "strict_filters",
                      "plan_limit_reached",
                      "validation_failed",
                      "deadline_exceeded",
                      "cancelled"
                    ]
                  },
                  "message": {
                    "type": "string"
                  },
                  "request_id": {
                    "type": "string"
                  },
                  "call_id": {
                    "type": "string"
                  },
                  "retry_after_ms": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "details": {
                    "type": "object",
                    "additionalProperties": {}
                  }
                },
                "required": [
                  "code",
                  "message"
                ]
              }
            },
            "required": [
              "error"
            ]
          }
        }
      }
    }
  }
}
```
