Welcome to the new Box Support website. Check out all the details here on what’s changed.

Box File URL format or how to get File URL from File ID

New post

Comments

5 comments

  • Rui Barbosa

    Hi Hiroyuki,

    Please tell me a bit more about what are you trying to do.

    If by file url you mean the download url, then you just need to add that fields to the query string.

    For example for file id 1204688948039:

    curl --location 'https://api.box.com/2.0/files/1204688948039?fields=id%2Ctype%2Cname%2Cdownload_url' \
    --header 'x-rep-hints: [pdf]' \
    --header 'Authorization: Bearer nVN...Z'

    I'm asking for id, type, name and download_url, and the response is:

    {
        "type": "file",
        "id": "1204688948039",
        "etag": "0",
        "name": "Get Started with Box.pdf",
      "download_url": "https://public.boxcloud.com/d/1/b1!djV6...ds./download"
    }

    So by default the /files/file_id: end point returns a simplified version of the file object. If you need more information, you can specify the fields you're interested in. You can take a look at the full file object attributes here.

    Now this download url is not a way to share the file, so it depends on your use case, meaning, what you want to do with this url.

    Let us know if this helps.

    0
    Comment actions Permalink
  • 白川博之

    Hi Rui,

    Thank you for quick reply! It's very helpful!!

    The file URL I meaned is simplest web access URL, which box users who has right access persmision can transit from https://app.box.com/folder/0, not mean download URL.

    I just want to point to the location of the file, and leave what to do with it up to the user.

    Thank you,

    0
    Comment actions Permalink
  • Rui Barbosa

    Hi Hiroyuki,

    In that case it is as simple as https://app.box.com/file/1016197618492, where the number is the file identifier, like you mentioned.

    I couldn't find the documentation about it either.

    Best regards

    0
    Comment actions Permalink
  • 白川博之

    Thank you. You have resolved my question. I appreciate it!

    0
    Comment actions Permalink
  • Krishan Singhal

    Is it also possible for it to be of the form https://companyname.app.box.com/file/123 or it will also be https://app.box.com/file/123?

    0
    Comment actions Permalink

Please sign in to leave a comment.