# Replace an object of an add-on's kind

URL: /docs/api/services/addonobject/replace

`PUT /apis/funcd.io/v1alpha1/namespaces/{namespace}/{plural}/{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 |
| --- | --- | --- | --- |
| `namespace` | path | string, required | The object's namespace. |
| `plural` | path | string, required | The plural of the object's add-on kind: the kind in lower case with an s. |
| `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

`AddonObject` 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": {
        "bindings": {
          "additionalProperties": false,
          "properties": {
            "job": {
              "description": "The Jobs whose runs the Function that funcd creates for an engineless object starts and reads, by their alias. Only an object of an engineless kind whose function is an image takes them.",
              "items": {
                "additionalProperties": false,
                "properties": {
                  "alias": {
                    "description": "The name that the code passes to ctx.job.start and ctx.job.get. Unique in the list.",
                    "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
                    "type": "string"
                  },
                  "job": {
                    "description": "A Job of the Function's namespace. While the Job is missing, a start on its alias answers 404, and a read still answers each run that a deleted Job left, until job.retention removes it.",
                    "maxLength": 63,
                    "minLength": 1,
                    "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
                    "type": "string"
                  }
                },
                "required": [
                  "alias",
                  "job"
                ],
                "type": "object"
              },
              "type": [
                "array",
                "null"
              ]
            },
            "secret": {
              "description": "Secrets of the namespace whose keys, those that its Addon's kind entry lists in secretKeys, reach the engine's environment. funcd asks Cedar, as the object, for secret::read on each: a missing Secret holds the object in Pending with SecretNotFound, and a forbidden one with BindingResolveFailed. A changed value replaces the engine. The Functions that funcd creates for the object read every key of them.",
              "items": {
                "maxLength": 63,
                "minLength": 1,
                "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
                "type": "string"
              },
              "type": [
                "array",
                "null"
              ]
            }
          },
          "type": "object",
          "description": "What the object's engine uses, and what the Functions that funcd creates for the object from its kinds' images use. An object of a settings kind takes none, nor does one of an engineless kind whose Function is a ref."
        },
        "config": {
          "description": "The object's settings, which its kind's schema checks: the config schema of its Addon's kind entry when the object runs an engine, else the contract of the kind's Function. Unset is an empty object."
        },
        "deletion": {
          "description": "What becomes of the engine's storage once the object is deleted and its engine is gone: retain, the default, moves it into the quarantine for storage.quarantineRetention, from which it comes back by hand with funcd stopped; delete removes it. A new object of the same name starts empty either way. For an object of an Engineless kind, delete holds the object at its deletion, with metadata.deletionTimestamp set, until its Function answers ok to a call that carried it as deleting; retain lets it go at once, and the Function forgets it.",
          "enum": [
            "retain",
            "delete"
          ],
          "type": "string"
        },
        "functions": {
          "description": "The object's own Function for a settings kind of its Addon, or for its own kind when that kind is Engineless, in place of the kind's function, so each copy of an App template applies its own objects. The objects it applies have no schema. A settings object names none.",
          "items": {
            "additionalProperties": false,
            "properties": {
              "kind": {
                "description": "A settings kind of the object's Addon, named once.",
                "type": "string"
              },
              "ref": {
                "description": "A Function of the object's namespace that binds the object in its bindings.addon, which funcd calls with the object's settings objects of the kind. In an App, a Function the App declares.",
                "maxLength": 63,
                "minLength": 1,
                "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
                "type": "string"
              }
            },
            "required": [
              "kind",
              "ref"
            ],
            "type": "object"
          },
          "type": [
            "array",
            "null"
          ]
        },
        "ingress": {
          "additionalProperties": false,
          "properties": {
            "auth": {
              "additionalProperties": false,
              "properties": {
                "mode": {
                  "description": "How the edge checks callers. authenticated requires a bearer token, or an X-Api-Key header, of an identity that RBAC lets get Functions in the namespace: 401 without a valid one, 403 when it may not; while server.auth.edge is off, every caller gets 401. open lets anonymous callers in. oidc signs callers in with the OIDCProvider that provider names, and passes the signed-in user to the code behind it in the X-Funcd-Principal headers. Empty takes the enclosing stance, if any, else the namespace's spec.edgeDefaults.auth.mode, else open.",
                  "enum": [
                    "",
                    "authenticated",
                    "open",
                    "oidc"
                  ],
                  "type": "string"
                },
                "provider": {
                  "description": "With mode oidc, the OIDCProvider of the namespace that signs callers in; required with oidc and refused with another mode.",
                  "maxLength": 63,
                  "minLength": 1,
                  "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
                  "type": "string"
                },
                "unauthenticated": {
                  "description": "With mode oidc, what a call that is not signed in gets: redirect, the default, sends a GET or HEAD navigation to the provider with 302 and gives any other call 401; 401 gives every such call 401; allow passes every call, with no principal. Refused with another mode.",
                  "enum": [
                    "",
                    "redirect",
                    "401",
                    "allow"
                  ],
                  "type": "string"
                }
              },
              "type": "object",
              "description": "How the edge checks callers at the resource's own address; unset, the namespace's spec.edgeDefaults.auth decides, else open. A Lake refuses it, since the Lake gateway checks each caller."
            },
            "enabled": {
              "description": "Turns the resource's own address on or off. Unset, it is on unless the namespace's spec.defaultExposure is explicit; a Lake's address is on only when this is true.",
              "type": "boolean"
            },
            "host": {
              "description": "The exact host of the resource's own address. Empty is the namespace's host, <namespace>.<server.baseDomain>, or, in the default namespace, any host that no other namespace reserves.",
              "type": "string"
            },
            "path": {
              "description": "The edge path of the resource's own address, which begins with / and does not end with / unless it is /. Empty is / when host is set, else /function/<name>, /site/<name> or /lake/<name> by kind.",
              "type": "string"
            }
          },
          "type": "object",
          "description": "Exposes the engine at the edge, on ingress.host under its Addon's basePath, while the object is Ready. Its own ingress.auth alone decides the stance, open when unset; ingress.path and the authenticated mode are refused. An object of a settings or an engineless kind takes none."
        },
        "kind": {
          "description": "The add-on's kind, which funcd sets from the path the object is written at.",
          "type": "string"
        },
        "resources": {
          "additionalProperties": false,
          "properties": {
            "cpu": {
              "description": "The CPU cap of the worker or engine it sizes, as a number of cores of at least 0.01, such as 0.5 or 2. Empty takes the default of the resource that declares it, or no cap when there is none. Only the containerd runtime enforces it.",
              "type": "string"
            },
            "memory": {
              "description": "The memory cap of the worker or engine it sizes, such as 256Mi or 4GiB: 1 to 15 digits and an optional binary unit, Ki, Mi, Gi or Ti, with or without a B, above zero. Empty takes the default of the resource that declares it, or no cap when there is none. Only the containerd runtime enforces it, and there a worker that uses more memory than the cap is killed.",
              "type": "string"
            }
          },
          "type": "object",
          "description": "The cpu and memory of the object's engine. An empty cpu or memory sets no limit, and a change replaces the running engine. An object of a settings or an engineless kind takes none."
        }
      },
      "type": "object"
    },
    "status": {
      "additionalProperties": false,
      "properties": {
        "addonRevision": {
          "description": "The AddonRevision whose spec the engine runs. A newer revision of the Addon moves no object: an edit of the object moves it to the Addon's current revision, and for an App's part, the App's revision moves it.",
          "maxLength": 63,
          "minLength": 1,
          "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
          "type": "string"
        },
        "address": {
          "description": "The engine's own address, its host and port, which only funcd reaches.",
          "type": "string"
        },
        "appRevision": {
          "description": "For an App's part, the AppRevision whose record for its kind it pins: the App's latest revision once that one is applied. A part moves forward only.",
          "maxLength": 63,
          "minLength": 1,
          "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
          "type": "string"
        },
        "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"
          ]
        },
        "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"
        },
        "restore": {
          "additionalProperties": false,
          "properties": {
            "file": {
              "description": "The copy's file name in the Addon's restore.path.",
              "type": "string"
            },
            "restore": {
              "description": "The Restore that placed the copy.",
              "maxLength": 63,
              "minLength": 1,
              "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
              "type": "string"
            },
            "state": {
              "description": "Loading while the engine starts with restore.env to load the copy; Loaded once the copy is gone, while the engine starts again without restore.env.",
              "enum": [
                "Loading",
                "Loaded"
              ],
              "type": "string"
            }
          },
          "required": [
            "restore",
            "file",
            "state"
          ],
          "type": "object",
          "description": "The in-place Restore whose copy the engine loads: it goes once an engine started without restore.env is Ready, or once that Restore has failed or is gone. While it stands, the namespace is held."
        },
        "workload": {
          "description": "The workload of the object's kind, which funcd stores at the object's first pass: Engineless for a kind whose objects run no engine, Engine once funcd has tried to start its engine. No call of its Function carries the object before then, and a deletion holds only an Engineless object. An Addon created again for the kind keeps it.",
          "enum": [
            "Function",
            "Job",
            "Engine",
            "Engineless"
          ],
          "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's metadata.namespace or metadata.name is not the path's, or If-Match and metadata.resourceVersion name two versions. | 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 body's kind is not the kind whose plural the path names. | Send the object to its own kind's plural. |
| 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 or namespaces do not allow it to replace an object in the namespace. | Use a credential whose role allows it, such as a developer of the namespace or an admin. |
| 404 | `urn:funcd:problem:not-found` | No object of that name exists in the namespace. | Check the name and the namespace. |
| 404 | `urn:funcd:problem:not-found` | No Addon registers the kind whose plural the path names. | Register the add-on first, or check the plural: the kind in lower case with an s. |
| 409 | `urn:funcd:problem:conflict` | The object has changed since the resourceVersion that If-Match or metadata.resourceVersion names. | Read the object again, apply the change to it, and send it with its new resourceVersion. |
| 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 namespace or 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. |
| 422 | `about:blank` | spec.config breaks the schema of its kind: the Addon's config schema for a kind that runs an engine, else what the contract of the kind's function.image says, in the revision that judges the write. The detail names the property. | Correct spec.config to fit the schema, or move the object's target to a newer revision of the Addon. |