{"record":{"id":"264999f5d07a4c6c","repo":"bitwarden/server","slug":"cipher-was-not-archived-ensure-the-provided-id-is","errorCode":null,"errorMessage":"Cipher was not archived. Ensure the provided ID is correct and you have permission to archive it.","messagePattern":"Cipher was not archived\\. 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":892,"sourceCode":"        {\n            await _collectionCipherRepository.RemoveCollectionsForManyCiphersAsync(model.OrganizationId, model.CipherIds, model.CollectionIds);\n        }\n        else\n        {\n            await _collectionCipherRepository.AddCollectionsForManyCiphersAsync(model.OrganizationId, model.CipherIds, model.CollectionIds);\n        }\n    }\n\n    [HttpPut(\"{id}/archive\")]\n    public async Task<CipherResponseModel> PutArchive(Guid id)\n    {\n        var userId = _userService.GetProperUserId(User).Value;\n\n        var archivedCipherOrganizationDetails = await _archiveCiphersCommand.ArchiveManyAsync([id], userId);\n\n        if (archivedCipherOrganizationDetails.Count == 0)\n        {\n            throw new BadRequestException(\"Cipher was not archived. Ensure the provided ID is correct and you have permission to archive it.\");\n        }\n\n        var archivedCipher = archivedCipherOrganizationDetails.First();\n        return new CipherResponseModel(archivedCipher, await _userService.GetUserByPrincipalAsync(User), await GetOrganizationAbilityAsync(archivedCipher), _globalSettings);\n    }\n\n    [HttpPut(\"archive\")]\n    public async Task<ListResponseModel<CipherResponseModel>> PutArchiveMany([FromBody] CipherBulkArchiveRequestModel model)\n    {\n        if (!_globalSettings.SelfHosted && model.Ids.Count() > 500)\n        {\n            throw new BadRequestException(\"You can only archive up to 500 items at a time.\");\n        }\n\n        var userId = _userService.GetProperUserId(User).Value;\n        var user = await _userService.GetUserByPrincipalAsync(User);\n\n        var cipherIdsToArchive = new HashSet<Guid>(model.Ids);","sourceCodeStart":874,"sourceCodeEnd":910,"githubUrl":"https://github.com/bitwarden/server/blob/e93b962371d80964556f5590c6615f5160a437a1/src/Api/Vault/Controllers/CiphersController.cs#L874-L910","documentation":"PUT /ciphers/{id}/archive (PutArchive) delegates to ArchiveManyAsync with a single id. If zero ciphers are archived — wrong id, not owned by the user, no edit permission, or an archived/deleted state — the server returns HTTP 400 telling the caller the id or permission is wrong.","triggerScenarios":"PUT /ciphers/{id}/archive where the id does not exist, belongs to another user, or the user lacks permission to archive it.","commonSituations":"Archiving a cipher that was deleted by another client; archiving an org cipher without edit rights; a stale/outdated cipher id after sync.","solutions":["Verify the cipher id is correct and that you own or can edit the cipher.","Re-sync the vault to confirm the cipher exists and isn't already archived/deleted.","If it is an org cipher, confirm your collection/org permissions grant edit rights."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"async function safeArchive(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 archive');\n  return api.put(`/ciphers/${id}/archive`);\n}","typeGuard":"function isArchivable(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}/archive`); }\ncatch (e) {\n  if (e?.response?.status === 400 && /not archived/i.test(e.response.data?.message ?? '')) {\n    await syncVault(); // re-check ownership/permissions, do not blindly retry\n  } else throw e;\n}","preventionTips":["Confirm you own or can edit the cipher before archiving.","Re-sync to ensure the id still exists and isn't already archived/deleted.","Check org/collection edit rights for org ciphers."],"tags":["cipher","archive","permissions","bad-request"],"backgroundTag":null,"analyzedSha":"e93b962371d80964556f5590c6615f5160a437a1","analyzedAt":"2026-08-13T14:22:19.382Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}