- Subscribe to RSS Feed
- Mark Thread as New
- Mark Thread as Read
- Float this Thread for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
I am implementing a "View Invoice PDF" feature on my webpage, allowing users to access their invoice PDFs via the following Square Sandbox URL:
https://app.squareupsandbox.com/invoices/{invoiceId}/attachments/pdf?inline=true
Currently, this functionality works if I am logged into the Square Dashboard on the same browser. However, when accessed from a different browser or by an unauthenticated user, the following authentication error occurs:
{
"errors": [
{
"category": "AUTHENTICATION_ERROR",
"code": "UNAUTHORIZED",
"detail": "This request could not be authorized."
}
]
}
This prevents users from viewing and downloading their invoice PDFs unless they are logged into Square. Is there a way to resolve this issue, or is authentication a strict requirement for accessing invoice attachments?
Best regards,

- Subscribe to RSS Feed
- Mark Thread as New
- Mark Thread as Read
- Float this Thread for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Hi @aZticot !
My recommendation would be to ask this question over in the Square Developer's Forum. Most of the moderators here are not super familiar with coding or APIs.
I think one of my friends @JTPets may have some insight, but not sure.
Sorry i could not be of more assistance, but the developer's forum will probably get you set in the right direction.

- Subscribe to RSS Feed
- Mark Thread as New
- Mark Thread as Read
- Float this Thread for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Hi @aZticot !
My recommendation would be to ask this question over in the Square Developer's Forum. Most of the moderators here are not super familiar with coding or APIs.
I think one of my friends @JTPets may have some insight, but not sure.
Sorry i could not be of more assistance, but the developer's forum will probably get you set in the right direction.

- Subscribe to RSS Feed
- Mark Thread as New
- Mark Thread as Read
- Float this Thread for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
I am not a developer and I have very little code skill myself. However it appears that you are using the sandbox which is for testing and not live production.
Change your urls and ensure you use a production api key and url

- Subscribe to RSS Feed
- Mark Thread as New
- Mark Thread as Read
- Float this Thread for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
I use AI for a lot of my own Square API issues, here is what the AI says as an additional reply:
The issue here is that Square's invoice PDF URLs are not publicly accessible and require authentication to view. This means:
- Authentication Required: The URL only works if the user is logged into Square with an account that has permission to view the invoice.
- Sandbox vs. Production: Even in the Square Sandbox environment, authentication is enforced.
- No Public Sharing: Unlike some other platforms that generate temporary public links, Square's invoice PDFs are restricted to authorized users.
Possible Solutions:
1. Use Square's API to Fetch the Invoice PDF
- Instead of relying on a direct URL, use Square’s API to fetch the invoice details and generate a downloadable PDF.
- You may need to proxy the request through your server if you want to offer the PDF to non-authenticated users.
2. Generate a Temporary Link
- If public sharing is required, consider using a cloud storage service (AWS S3, Google Drive, etc.) to store and serve the PDFs after fetching them via Square’s API.
3. Embed a Secure Login Mechanism
- If your users should have access, authenticate them via OAuth to allow them to fetch their invoices.

- Subscribe to RSS Feed
- Mark Thread as New
- Mark Thread as Read
- Float this Thread for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
I appreciate you @JTPets !