# Replace an Addon

URL: /docs/api/services/addon/replace

`PUT /apis/funcd.io/v1alpha1/addons/{name}`

## Authentication

One of:

- `bearer`: A credential of funcd's config, sent as Authorization: Bearer followed by its token.
- `apiKey`: A credential of funcd's config, sent in the X-Api-Key header.

## Parameters

| Parameter | In | Type | Description |
| --- | --- | --- | --- |
| `name` | path | string, required | The object's name. |
| `dryRun` | query | boolean | Admit the write and store nothing. |
| `If-Match` | header | string | One strong entity-tag, the quoted resourceVersion, or *: the write is conditional on it. |

## Body

`Addon` as `application/json`, required.

```json
{
  "additionalProperties": false,
  "properties": {
    "apiVersion": {
      "type": "string"
    },
    "kind": {
      "type": "string"
    },
    "metadata": {
      "additionalProperties": false,
      "properties": {
        "creationTimestamp": {
          "description": "When funcd created the object.",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
          "patternDescription": "an RFC3339 UTC timestamp with exactly 3 fractional digits (2026-10-07T20:03:35.965Z)",
          "type": "string"
        },
        "deletionTimestamp": {
          "description": "When funcd held the object at its deletion: an object of an Engineless add-on kind with deletion: delete stays, deleting, until its Function has destroyed what it holds. funcd sets it on no other object, and a write keeps it.",
          "format": "date-time",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
          "patternDescription": "an RFC3339 UTC timestamp with exactly 3 fractional digits (2026-10-07T20:03:35.965Z)",
          "type": "string"
        },
        "finalizers": {
          "description": "funcd does not read it.",
          "items": {
            "type": "string"
          },
          "type": [
            "array",
            "null"
          ]
        },
        "generateName": {
          "description": "A prefix from which funcd makes the name, adding a random suffix, when a create leaves name empty.",
          "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
          "type": "string"
        },
        "generation": {
          "description": "Set by funcd: 1 when the object is created, then one more each time its spec changes.",
          "format": "int64",
          "type": "integer"
        },
        "name": {
          "description": "The object's name, unique among the objects of its kind in its namespace. A create may leave it empty and set generateName instead.",
          "maxLength": 63,
          "minLength": 1,
          "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
          "type": "string"
        },
        "namespace": {
          "description": "The namespace the object belongs to. A cluster-scoped kind has none.",
          "maxLength": 63,
          "minLength": 1,
          "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
          "type": "string"
        },
        "ownerReferences": {
          "description": "The objects that own this one. funcd deletes an owned object when its owner goes.",
          "items": {
            "additionalProperties": false,
            "properties": {
              "blockOwnerDeletion": {
                "description": "funcd does not read it.",
                "type": "boolean"
              },
              "controller": {
                "description": "Whether this owner is the one that manages the object.",
                "type": "boolean"
              },
              "kind": {
                "description": "The kind of the object it names.",
                "type": "string"
              },
              "name": {
                "description": "The name of the object it names.",
                "maxLength": 63,
                "minLength": 1,
                "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
                "type": "string"
              },
              "namespace": {
                "description": "The namespace of the object it names.",
                "maxLength": 63,
                "minLength": 1,
                "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
                "type": "string"
              },
              "uid": {
                "description": "The owner's unique ID.",
                "type": "string"
              }
            },
            "required": [
              "uid",
              "kind",
              "name"
            ],
            "type": "object"
          },
          "type": [
            "array",
            "null"
          ]
        },
        "resourceGroup": {
          "description": "The resource group the object belongs to, within its namespace.",
          "maxLength": 63,
          "minLength": 1,
          "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
          "type": "string"
        },
        "resourceVersion": {
          "description": "An opaque version of the stored object, which funcd sets. An update that sends it gets a conflict when the object changed since; compare it for equality only.",
          "type": "string"
        },
        "tags": {
          "additionalProperties": {
            "type": "string"
          },
          "description": "Labels on the object, as keys and values.",
          "type": "object"
        },
        "uid": {
          "description": "The object's unique ID, which funcd sets when it creates the object.",
          "type": "string"
        }
      },
      "type": "object"
    },
    "spec": {
      "additionalProperties": false,
      "properties": {
        "runtimes": {
          "description": "The runtimes that the add-on ships, each an image and the workloads it serves. At most one entry runs the add-on's kind; an Addon whose entries run none adds no kind, and may gain one once.",
          "items": {
            "additionalProperties": false,
            "properties": {
              "attributes": {
                "additionalProperties": false,
                "properties": {
                  "basePath": {
                    "description": "The path under which the edge serves an object's engine, which the engine gets as it was called. It begins with /, does not end with / unless it is /, and holds no empty, . or .. segment. Empty is /.",
                    "type": "string"
                  },
                  "config": {
                    "description": "An Engine entry's JSON Schema of the objects' spec.config, within funcd's contract profile: closed objects, and no $ref. funcd refuses an object whose config breaks it; an object stored before a change that its config breaks waits in Pending with ConfigInvalid, with no engine. An Engineless entry sets none: its Function's contract describes its objects."
                  },
                  "env": {
                    "additionalProperties": {
                      "type": "string"
                    },
                    "description": "The engine's environment. Each value is a literal, or a single ${{ }} expression over config, such as ${{ config.issuer }}, which funcd checks against the config schema when the Addon is applied. A value that is not a string reaches the engine as its JSON; one that fails holds the object in Pending with EnvInvalid.",
                    "type": "object"
                  },
                  "function": {
                    "additionalProperties": false,
                    "properties": {
                      "image": {
                        "description": "A Function's artifact, pinned by digest, from a registry that addons.registries lists. funcd creates the Function from it and puts back what differs: it runs the export handle, has no address of its own, and binds the object that runs an engine, the object's Secrets and an engineless object's Jobs. The artifact's contract describes the objects, and funcd refuses one whose config breaks it. Set either image or ref.",
                        "type": "string"
                      },
                      "ref": {
                        "description": "The name of an existing Function in the object's namespace. funcd does not create or change it, and the objects wait while it is missing. Their config has no schema, and the kind takes no rules. Set either image or ref.",
                        "maxLength": 63,
                        "minLength": 1,
                        "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
                        "type": "string"
                      }
                    },
                    "type": "object",
                    "description": "An Engineless entry's Function, which reconciles the objects of its kind and which funcd calls with their list: an image, from which funcd creates one Function for each object, or an existing Function of each object's namespace. An object may name its own in spec.functions."
                  },
                  "kind": {
                    "description": "The namespaced kind that the entry runs: an upper-case letter, then 1 to 62 letters or digits. Its objects are served at /apis/funcd.io/v1alpha1/namespaces/<namespace>/<plural>, where the plural is the kind in lower case with an s. funcd refuses a kind that is its own, or whose plural is a path funcd serves or another Addon's plural, whatever the case. An Addon gains its kind once: it cannot change or go.",
                    "pattern": "^[A-Z][A-Za-z0-9]{1,62}$",
                    "type": "string"
                  },
                  "port": {
                    "description": "The port that the engine serves on, in its own network namespace; an Engine entry requires it. Only funcd reaches it.",
                    "format": "int64",
                    "maximum": 65535,
                    "minimum": 1,
                    "type": "integer"
                  },
                  "privatePaths": {
                    "description": "Paths under basePath that the edge answers with 404, however a caller spells them; funcd reaches them at the engine's own address. Each has basePath's form and lies under it.",
                    "items": {
                      "type": "string"
                    },
                    "type": [
                      "array",
                      "null"
                    ]
                  },
                  "readiness": {
                    "additionalProperties": false,
                    "properties": {
                      "path": {
                        "description": "The path that funcd sends GET to on the engine's port. The object turns Ready once it answers 200.",
                        "type": "string"
                      }
                    },
                    "required": [
                      "path"
                    ],
                    "type": "object",
                    "description": "How funcd learns that an object's engine is ready; an Engine entry requires it."
                  },
                  "restore": {
                    "additionalProperties": false,
                    "properties": {
                      "env": {
                        "additionalProperties": {
                          "type": "string"
                        },
                        "description": "The environment of the start that loads the copy, laid over env. Each value is a literal, or a single ${{ }} expression over config and restore, such as ${{ \"file:\" + restore.file }}: restore.file is the copy's path in the engine.",
                        "type": "object"
                      },
                      "path": {
                        "description": "The folder in the engine where funcd puts the copy that the next start loads: under storage.path, and neither snapshot.path nor inside it. funcd empties it before it writes the copy, and removes the copy once the engine that loaded it is Ready.",
                        "type": "string"
                      },
                      "timeout": {
                        "description": "How long an in-place Restore waits for the engine to load the copy and start again without restore.env, from 1s to 1h; unset is 10m. Past it, the Restore fails with reason RestoreTimedOut and the namespace stays held.",
                        "pattern": "^([0-9]+h([0-9]+m)?([0-9]+s)?([0-9]+ms)?|[0-9]+m([0-9]+s)?([0-9]+ms)?|[0-9]+s([0-9]+ms)?|[0-9]+ms)$",
                        "patternDescription": "a duration: whole numbers with the units h, m, s and ms, largest unit first (10m, 1h30m, 500ms)",
                        "type": "string"
                      }
                    },
                    "required": [
                      "path"
                    ],
                    "type": "object",
                    "description": "How the engine loads a copy at its start, which an in-place Restore of an object puts in place. Unset, an object of the add-on cannot be restored."
                  },
                  "resync": {
                    "description": "How often funcd sends an Engineless kind's lists again with no change, from 1s to 24h; unset is 10m.",
                    "pattern": "^([0-9]+h([0-9]+m)?([0-9]+s)?([0-9]+ms)?|[0-9]+m([0-9]+s)?([0-9]+ms)?|[0-9]+s([0-9]+ms)?|[0-9]+ms)$",
                    "patternDescription": "a duration: whole numbers with the units h, m, s and ms, largest unit first (10m, 1h30m, 500ms)",
                    "type": "string"
                  },
                  "secretKeys": {
                    "description": "The keys of an object's bound Secrets that reach the engine's environment. A bound Secret's other keys do not.",
                    "items": {
                      "type": "string"
                    },
                    "type": [
                      "array",
                      "null"
                    ]
                  },
                  "settings": {
                    "description": "Kinds of settings objects that the add-on adds beside kind. An object of one runs no engine: the kind's Function applies the objects of each target through the target's engine.",
                    "items": {
                      "additionalProperties": false,
                      "properties": {
                        "constraints": {
                          "additionalProperties": false,
                          "properties": {
                            "count": {
                              "additionalProperties": false,
                              "properties": {
                                "perNamespace": {
                                  "description": "The most objects of the kind in a namespace.",
                                  "format": "int64",
                                  "minimum": 0,
                                  "type": "integer"
                                },
                                "perTarget": {
                                  "description": "The most objects of the kind that name one target.",
                                  "format": "int64",
                                  "minimum": 0,
                                  "type": "integer"
                                }
                              },
                              "type": "object",
                              "description": "How many objects of the kind a target or a namespace holds at most; 0 is no limit."
                            },
                            "immutable": {
                              "description": "Fields under spec.config that a replace cannot change.",
                              "items": {
                                "type": "string"
                              },
                              "type": [
                                "array",
                                "null"
                              ]
                            },
                            "rules": {
                              "description": "Conditions over object, oldObject and others that a write must meet.",
                              "items": {
                                "additionalProperties": false,
                                "properties": {
                                  "message": {
                                    "description": "What a refusal says.",
                                    "type": "string"
                                  },
                                  "rule": {
                                    "description": "A single ${{ }} condition over object, oldObject (on a replace) and others.",
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "rule",
                                  "message"
                                ],
                                "type": "object"
                              },
                              "type": [
                                "array",
                                "null"
                              ]
                            },
                            "unique": {
                              "description": "Fields under spec.config whose value no two objects of the kind in a namespace share.",
                              "items": {
                                "type": "string"
                              },
                              "type": [
                                "array",
                                "null"
                              ]
                            }
                          },
                          "type": "object",
                          "description": "What an object must keep at admission, beside its schema, which is its Function's contract."
                        },
                        "function": {
                          "additionalProperties": false,
                          "properties": {
                            "image": {
                              "description": "A Function's artifact, pinned by digest, from a registry that addons.registries lists. funcd creates the Function from it and puts back what differs: it runs the export handle, has no address of its own, and binds the object that runs an engine, the object's Secrets and an engineless object's Jobs. The artifact's contract describes the objects, and funcd refuses one whose config breaks it. Set either image or ref.",
                              "type": "string"
                            },
                            "ref": {
                              "description": "The name of an existing Function in the object's namespace. funcd does not create or change it, and the objects wait while it is missing. Their config has no schema, and the kind takes no rules. Set either image or ref.",
                              "maxLength": 63,
                              "minLength": 1,
                              "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
                              "type": "string"
                            }
                          },
                          "type": "object",
                          "description": "The Function that applies a target's objects: an image, from which funcd creates one Function for each target that an object of the kind names, or an existing Function of the target's namespace. A target may name its own in its spec.functions."
                        },
                        "kind": {
                          "description": "The settings kind, a kind name as the Addon's kind is, served at its plural.",
                          "type": "string"
                        },
                        "resync": {
                          "description": "How often funcd sends a target's objects again with no change, from 1s to 24h; unset is 10m.",
                          "pattern": "^([0-9]+h([0-9]+m)?([0-9]+s)?([0-9]+ms)?|[0-9]+m([0-9]+s)?([0-9]+ms)?|[0-9]+s([0-9]+ms)?|[0-9]+ms)$",
                          "patternDescription": "a duration: whole numbers with the units h, m, s and ms, largest unit first (10m, 1h30m, 500ms)",
                          "type": "string"
                        },
                        "target": {
                          "description": "The string field under spec.config that names the object's target, such as spec.config.provider. A replace of the Addon cannot change it.",
                          "type": "string"
                        }
                      },
                      "required": [
                        "kind",
                        "target",
                        "function"
                      ],
                      "type": "object"
                    },
                    "type": [
                      "array",
                      "null"
                    ]
                  },
                  "snapshot": {
                    "additionalProperties": false,
                    "properties": {
                      "path": {
                        "description": "The folder in the engine where it writes its copies: under storage.path, and neither restore.path nor inside it. A Backup copies the newest regular file there whose name does not end in ~ and that has not changed for 2 s, as it is.",
                        "type": "string"
                      }
                    },
                    "required": [
                      "path"
                    ],
                    "type": "object",
                    "description": "Where the engine writes its own consistent copies, which a Backup of an object copies. Unset, a Backup that names an object of the add-on fails with reason NoSnapshot, and a resourceGroup scope leaves the add-on's objects out."
                  },
                  "storage": {
                    "additionalProperties": false,
                    "properties": {
                      "gid": {
                        "description": "The group ID that owns the directory.",
                        "format": "int64",
                        "minimum": 0,
                        "type": "integer"
                      },
                      "path": {
                        "description": "Where the directory is mounted in the engine, an absolute path.",
                        "type": "string"
                      },
                      "uid": {
                        "description": "The user ID that owns the directory: the user the engine's image runs as.",
                        "format": "int64",
                        "minimum": 0,
                        "type": "integer"
                      }
                    },
                    "required": [
                      "path"
                    ],
                    "type": "object",
                    "description": "A directory that outlives each object's engine, kept across a replaced engine and funcd's restarts. Unset, the engine keeps nothing."
                  }
                },
                "type": "object",
                "description": "The entry's fields for its workloads: an Engine entry's kind, config, settings and engine fields; an Engineless entry's kind, config, function and resync. A Function or Job entry takes none."
              },
              "image": {
                "description": "The image, pinned by digest as <repository>@sha256:<64 hex digits>, from a registry that addons.registries lists, and pulled as an engine's. A registry taken out of that list stops no worker or engine, and refuses the Addon's next change.",
                "pattern": "^[^:@\\s]+(:[0-9]+/[^:@\\s]+)?@sha256:[a-f0-9]{64}$",
                "type": "string"
              },
              "name": {
                "description": "The runtime's name, which a Function's or a Job's spec.runtime names: a DNS label that is none of funcd's runtimes (nodejs22, python314, duckdb, rqlite), does not start with node or python, is no key of runtime.containerd.imageOverride, and that no other Addon ships.",
                "maxLength": 63,
                "minLength": 1,
                "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
                "type": "string"
              },
              "workloads": {
                "description": "What the entry serves: Function and Job, which Functions and Jobs may name in spec.runtime; Engine, alone, which runs one engine of the image per object of the entry's kind; or Engineless, alone, whose kind's objects run no engine and no image: a Function of their namespace reconciles them.",
                "items": {
                  "enum": [
                    "Function",
                    "Job",
                    "Engine",
                    "Engineless"
                  ],
                  "type": "string"
                },
                "minItems": 1,
                "type": [
                  "array",
                  "null"
                ]
              }
            },
            "required": [
              "name",
              "workloads"
            ],
            "type": "object"
          },
          "minItems": 1,
          "type": [
            "array",
            "null"
          ]
        }
      },
      "required": [
        "runtimes"
      ],
      "type": "object"
    },
    "status": {
      "additionalProperties": false,
      "properties": {
        "conditions": {
          "description": "The conditions that explain the phase.",
          "items": {
            "additionalProperties": false,
            "properties": {
              "lastTransitionTime": {
                "description": "When the status last changed.",
                "format": "date-time",
                "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
                "patternDescription": "an RFC3339 UTC timestamp with exactly 3 fractional digits (2026-10-07T20:03:35.965Z)",
                "type": "string"
              },
              "message": {
                "description": "A sentence that explains the status.",
                "type": "string"
              },
              "observedGeneration": {
                "description": "The object's generation when funcd set the condition.",
                "format": "int64",
                "type": "integer"
              },
              "reason": {
                "description": "A short CamelCase reason for the status.",
                "type": "string"
              },
              "status": {
                "description": "Whether the condition holds.",
                "type": "string"
              },
              "type": {
                "description": "What the condition reports, such as Ready.",
                "type": "string"
              }
            },
            "required": [
              "type",
              "status"
            ],
            "type": "object"
          },
          "type": [
            "array",
            "null"
          ]
        },
        "currentRevision": {
          "description": "The AddonRevision of the Addon's latest spec: an object created, or edited outside an App, pins it, and an App's new revision records it. Empty until funcd has stamped the Addon's first revision.",
          "maxLength": 63,
          "minLength": 1,
          "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
          "type": "string"
        },
        "observedGeneration": {
          "description": "The generation of the spec that funcd last acted on.",
          "format": "int64",
          "type": "integer"
        },
        "phase": {
          "description": "Where the object is in its lifecycle.",
          "enum": [
            "Pending",
            "Deploying",
            "Ready",
            "Idle",
            "Degraded",
            "Failed",
            "Terminating"
          ],
          "type": "string"
        }
      },
      "type": "object"
    }
  },
  "required": [
    "metadata",
    "spec",
    "apiVersion",
    "kind"
  ],
  "type": "object"
}
```

## Answers

| Status | Problem type | When | What to do |
| --- | --- | --- | --- |
| 200 |  | OK |  |
| 400 | `urn:funcd:problem:invalid` | The If-Match header is not one strong entity-tag, such as "42", or *. | Send one If-Match line with the quoted resourceVersion, or *. |
| 400 | `urn:funcd:problem:invalid` | A field breaks a rule that the schema cannot hold, which the detail names. | Correct the field that the detail names. |
| 400 | `urn:funcd:problem:invalid` | The body sets metadata.namespace, which the detail compares with the path's empty namespace, or its metadata.name is not the path's, or If-Match and metadata.resourceVersion name two versions. | Leave metadata.namespace empty, and send the object to its own path, with at most one version. |
| 400 | `about:blank` | The body is missing or is not JSON. | Send a JSON body. |
| 400 | `urn:funcd:problem:invalid` | The Addon's kind or a settings kind is a kind of funcd's, another kind of the Addon or a path that funcd serves, whatever the case; a replace changes or drops the kind, or changes a settings kind's target; or a runtime's name is one of funcd's runtimes or a key of runtime.containerd.imageOverride. | Choose another kind or runtime name. A new kind needs a new Addon, and a new target a new settings kind. |
| 400 | `urn:funcd:problem:invalid` | The registry of a runtime's image, or of a kind's function.image, is not one that addons.registries lists. | Use an image from a listed registry, or ask the operator to list its registry. |
| 400 | `urn:funcd:problem:invalid` | The kind entry's config is not a JSON Schema in funcd's contract profile, or an env value is not a literal or a single ${{ }} expression that the schema types. | Correct the field that the detail names. |
| 401 | `urn:funcd:problem:unauthorized` | The request carries no bearer token or API key, or one that funcd does not know. | Send a credential of funcd's config as a bearer token in the Authorization header, or in X-Api-Key. |
| 403 | `urn:funcd:problem:forbidden` | The credential's role does not allow it to replace an Addon. | Use an admin's credential. |
| 404 | `urn:funcd:problem:not-found` | No Addon of that name exists. | Check the name. |
| 409 | `urn:funcd:problem:conflict` | The Addon has changed since the resourceVersion that If-Match or metadata.resourceVersion names. | Read the Addon again, apply the change to it, and send it with its new resourceVersion. |
| 409 | `urn:funcd:problem:conflict` | Another Addon registers the same kind or the same plural, whatever the case, or ships a runtime of the same name. | Choose another kind or runtime name, or change the other Addon. |
| 413 | `urn:funcd:problem:payload-too-large` | The body is larger than 1 MiB. | Send a smaller body. |
| 415 | `about:blank` | The Content-Type of the body is not JSON. | Send the body as application/json. |
| 422 | `about:blank` | The name in the path is not a DNS-1123 label. | Use at most 63 lowercase letters, digits and hyphens, starting and ending with a letter or a digit. |
| 422 | `about:blank` | The query holds a parameter that the operation does not take. | Send only the parameters that the operation lists. |
| 422 | `about:blank` | The dryRun parameter is neither true nor false. | Send dryRun=true, or leave it out. |
| 422 | `about:blank` | The body breaks the schema: a field that it does not know, of the wrong type or past its limits. | Correct the field at the location that the detail gives. |