{"record":{"id":"9965a23df2c66228","repo":"bitwarden/server","slug":"cipher-was-not-unarchived-ensure-the-provided-id","errorCode":null,"errorMessage":"Cipher was not unarchived. Ensure the provided ID is correct and you have permission to archive it.","messagePattern":"Cipher was not unarchived\\. Ensure the provided ID is correct and you have permission to archive it\\.","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"src/Api/Vault/Controllers/CiphersController.cs","lineNumber":1092,"sourceCode":"            !await CanDeleteOrRestoreCipherAsAdminAsync(new Guid(model.OrganizationId), cipherIds))\n        {\n            throw new NotFoundException();\n        }\n\n        var userId = _userService.GetProperUserId(User).Value;\n        await _cipherService.SoftDeleteManyAsync(cipherIds, userId, new Guid(model.OrganizationId), true);\n    }\n\n    [HttpPut(\"{id}/unarchive\")]\n    public async Task<CipherResponseModel> PutUnarchive(Guid id)\n    {\n        var userId = _userService.GetProperUserId(User).Value;\n\n        var unarchivedCipherDetails = await _unarchiveCiphersCommand.UnarchiveManyAsync([id], userId);\n\n        if (unarchivedCipherDetails.Count == 0)\n        {\n            throw new BadRequestException(\"Cipher was not unarchived. Ensure the provided ID is correct and you have permission to archive it.\");\n        }\n\n        var unarchivedCipher = unarchivedCipherDetails.First();\n        return new CipherResponseModel(unarchivedCipher,\n            await _userService.GetUserByPrincipalAsync(User),\n            await GetOrganizationAbilityAsync(unarchivedCipher),\n            _globalSettings\n        );\n    }\n\n    [HttpPut(\"unarchive\")]\n    public async Task<ListResponseModel<CipherResponseModel>> PutUnarchiveMany([FromBody] CipherBulkUnarchiveRequestModel model)\n    {\n        if (!_globalSettings.SelfHosted && model.Ids.Count() > 500)\n        {\n            throw new BadRequestException(\"You can only unarchive up to 500 items at a time.\");\n        }\n","sourceCodeStart":1074,"sourceCodeEnd":1110,"githubUrl":"https://github.com/bitwarden/server/blob/e93b962371d80964556f5590c6615f5160a437a1/src/Api/Vault/Controllers/CiphersController.cs#L1074-L1110","documentation":"PUT /ciphers/{id}/unarchive (PutUnarchive) delegates to UnarchiveManyAsync with a single id. If zero ciphers are unarchived — wrong id, not owned, no permission, or the cipher isn't archived — the server returns HTTP 400. (Note: the message text erroneously says 'archive it' rather than 'unarchive it', but the cause is the unarchive operation.)","triggerScenarios":"PUT /ciphers/{id}/unarchive where the id does not exist, belongs to another user, lacks permission, or is not currently archived.","commonSituations":"Unarchiving a cipher that was permanently deleted by another client; unarchiving an org cipher without edit rights; a stale cipher id after sync.","solutions":["Verify the cipher id is correct, owned/editable, and is actually in an archived state.","Re-sync the vault to refresh cipher state before retrying.","For org ciphers, confirm edit permission on the relevant collection."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"async function safeUnarchive(id) {\n  const c = await api.get(`/ciphers/${id}`).catch(() => null);\n  if (!c || !c.editable) throw new Error('Cipher missing or not editable; cannot unarchive');\n  return api.put(`/ciphers/${id}/unarchive`);\n}","typeGuard":"function isUnarchivable(cipher: { id?: string; editable?: boolean; deletedDate?: string | null } | null): boolean {\n  return !!cipher && !!cipher.id && cipher.editable === true && !cipher.deletedDate;\n}","tryCatchPattern":"try { await api.put(`/ciphers/${id}/unarchive`); }\ncatch (e) {\n  if (e?.response?.status === 400 && /not unarchived/i.test(e.response.data?.message ?? '')) {\n    await syncVault(); // verify state/permissions; note the server message erroneously says 'archive'\n  } else throw e;\n}","preventionTips":["Confirm the cipher is actually archived and you can edit it before unarchiving.","Re-sync to refresh state; the item may have been permanently deleted.","Check org/collection edit rights for org ciphers."],"tags":["cipher","unarchive","permissions","bad-request"],"backgroundTag":null,"analyzedSha":"e93b962371d80964556f5590c6615f5160a437a1","analyzedAt":"2026-08-13T14:22:19.382Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}