> ## Documentation Index
> Fetch the complete documentation index at: https://developer.box.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Restore File

export const MultiRelatedLinks = ({sections = []}) => {
  if (!sections || sections.length === 0) {
    return null;
  }
  return <div className="space-y-8">
      {sections.map((section, index) => <RelatedLinks key={index} title={section.title} items={section.items} />)}
    </div>;
};

export const RelatedLinks = ({title, items = []}) => {
  const getBadgeClass = badge => {
    if (!badge) return "badge-default";
    const badgeType = badge.toLowerCase().replace(/\s+/g, "-");
    return `badge-${badge === "ガイド" ? "guide" : badgeType}`;
  };
  if (!items || items.length === 0) {
    return null;
  }
  return <div className="my-8">
      {}
      <h3 className="text-sm font-bold uppercase tracking-wider mb-4">{title}</h3>

      {}
      <div className="flex flex-col gap-3">
        {items.map((item, index) => <a key={index} href={item.href} className="py-2 px-3 rounded related_link hover:bg-[#f2f2f2] dark:hover:bg-[#111827] flex items-center gap-3 group no-underline hover:no-underline border-b-0">
            {}
            <span className={`px-2 py-1 rounded-full text-xs font-semibold uppercase tracking-wide flex-shrink-0 ${getBadgeClass(item.badge)}`}>
              {item.badge}
            </span>

            {}
            <span className="text-base">{item.label}</span>
          </a>)}
      </div>
    </div>;
};

To restore a file that has been moved to the trash, but has not yet been
purged, make a `POST` request to the `/files/:file_id` endpoint. This will
place the file in the original folder if it is still available, or you
optionally can specify a `parent` folder.

<CodeGroup>
  ```sh cURL theme={null}
  curl -i -X POST "https://api.box.com/2.0/files/12345" \
       -H "authorization: Bearer <ACCESS_TOKEN>"
  ```

  ```typescript Node/TypeScript v10 theme={null}
  await client.trashedFiles.restoreFileFromTrash(file.id);
  ```

  ```python Python v10 theme={null}
  client.trashed_files.restore_file_from_trash(file.id)
  ```

  ```cs .NET v10 theme={null}
  await client.TrashedFiles.RestoreFileFromTrashAsync(fileId: file.Id);
  ```

  ```swift Swift v10 theme={null}
  try await client.trashedFiles.restoreFileFromTrash(fileId: file.id)
  ```

  ```java Java v10 theme={null}
  client.getTrashedFiles().restoreFileFromTrash(file.getId())
  ```

  ```java Java v5 theme={null}
  String fileID = "125367";
  String newName = "Presentation 2018 ORIGINAL.pptx";
  String newParentID = "98765";

  BoxTrash trash = new BoxTrash(api);
  // Avoid conflicts at the original location
  trash.restoreFile(fileID, newName, newParentID);
  ```

  ```python Python v4 theme={null}
  file_to_restore = client.file(file_id='11111')
  restored_file = client.trash().restore_item(file_to_restore)
  print(f'File ID is {restored_file.id} and name is {restored_file.name}')
  ```

  ```cs .NET v6 theme={null}
  var requestParams = new BoxFileRequest()
  {
      Name = "Name in case of conflict",
      Parent = new BoxRequestEntity()
      {
          // File will be placed in this folder if original location no longer exists
          Id = "12345" 
      }
  };
  BoxFile restoredFile = await client.FilesManager.RestoreTrashedAsync(requestParams);
  ```

  ```javascript Node v4 theme={null}
  client.files.restoreFromTrash(
  	'11111',
  	{
  		// New name in case of conflict
  		name: 'New Name',
  		// File will be placed in this folder if original location no longer exists
  		parent_id: '0'
  	})
  	.then(restoredFile => {
  		/* trashedFile -> {
  			type: 'file',
  			id: '11111',
  			sequence_id: '2',
  			etag: '2',
  			sha1: '4bd9e98652799fc57cf9423e13629c151152ce6c',
  			name: 'Screenshot_1_30_13_6_37_PM.png',
  			description: '',
  			size: 163265,
  			path_collection: 
  			{ total_count: 1,
  				entries: 
  				[ { type: 'folder',
  					id: '0',
  					sequence_id: null,
  					etag: null,
  					name: 'All Files' } ] },
  			created_at: '2013-01-30T18:43:56-08:00',
  			modified_at: '2013-01-30T18:44:00-08:00',
  			trashed_at: null,
  			purged_at: null,
  			content_created_at: '2013-01-30T18:43:56-08:00',
  			content_modified_at: '2013-01-30T18:44:00-08:00',
  			created_by: 
  			{ type: 'user',
  				id: '33333',
  				name: 'Example User',
  				login: 'user@example.com' },
  			modified_by: 
  			{ type: 'user',
  				id: '33333',
  				name: 'Example User',
  				login: 'user@example.com' },
  			owned_by: 
  			{ type: 'user',
  				id: '33333',
  				name: 'Example User',
  				login: 'user@example.com' },
  			shared_link: null,
  			parent: 
  			{ type: 'folder',
  				id: '0',
  				sequence_id: null,
  				etag: null,
  				name: 'All Files' },
  			item_status: 'active' }
  		*/
  	});
  ```
</CodeGroup>

<RelatedLinks
  title="RELATED APIS"
  items={[
  { label: "Restore file", href: "/reference/post-files-id", badge: "POST" },
  { label: "Delete file", href: "/reference/delete-files-id", badge: "DELETE" }
]}
/>

<RelatedLinks
  title="RELATED GUIDES"
  items={[
  { label: "Permanently Delete File", href: "/guides/trash/permanently-delete-file", badge: "GUIDE" }
]}
/>

<RelatedLinks
  title="RELATED RESOURCES"
  items={[
  { label: "Files", href: "/guides/files/index", badge: "GUIDE" }
]}
/>
