Space API Error: The AWS Access Key Id you provided does not exist in our records

Posted July 7, 2021 564 views
Node.jsAPIDigitalOcean Spaces

I am trying to upload files to DO spaces, using NodeJS. I am following thistutorial to generate space keys. but when I am trying to upload the files using AWS-SDK it returns error.

InvalidAccessKeyId: The AWS Access Key Id you provided does not exist in our records.
    at Request.extractError (D:\upwork\Oh-D\media-upload\node_modules\aws-sdk\lib\services\s3.js:714:35)
    at Request.callListeners (D:\upwork\Oh-D\media-upload\node_modules\aws-sdk\lib\sequential_executor.js:106:20)
    at Request.emit (D:\upwork\Oh-D\media-upload\node_modules\aws-sdk\lib\sequential_executor.js:78:10)
    at Request.emit (D:\upwork\Oh-D\media-upload\node_modules\aws-sdk\lib\request.js:688:14)
    at Request.transition (D:\upwork\Oh-D\media-upload\node_modules\aws-sdk\lib\request.js:22:10)
    at AcceptorStateMachine.runTo (D:\upwork\Oh-D\media-upload\node_modules\aws-sdk\lib\state_machine.js:14:12)
    at D:\upwork\Oh-D\media-upload\node_modules\aws-sdk\lib\state_machine.js:26:10
    at Request.<anonymous> (D:\upwork\Oh-D\media-upload\node_modules\aws-sdk\lib\request.js:38:9)
    at Request.<anonymous> (D:\upwork\Oh-D\media-upload\node_modules\aws-sdk\lib\request.js:690:12)
    at Request.callListeners (D:\upwork\Oh-D\media-upload\node_modules\aws-sdk\lib\sequential_executor.js:116:18)

I have tried generating and using the different keys, but it doesn’t work.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi there,

This sounds like either the key is not correct or the endpoint that you are using is not correct.

Can you share the code snippet here? Make sure to hide any sensitive information before posting the reply.

On another note, here is a step-by-step tutorial on how to set up Node.js with DigitalOcean Spaces:


by Tania Rascia
Create a Node.js app to upload a file to your DigitalOcean Space
  • I have checked the key and endpoint is correct. I have copied the endpoint from the settings of the space.
    Here is the code snippet.

    const aws = require("aws-sdk");
    const fs = require("fs");
    const path = require("path");
    const spaceEndpoint = aws.Endpoint("");
    const AWSS3 = new aws.S3({
      endpoint: spaceEndpoint,
      accessKeyId: process.env.AWS_ACCESS_KEY_ID,
      secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
     * * upload given file to the DO space
     * @param {string} filepath path of the files to be uploaded
     * @returns path of uploaded file
    const uploadFileToSpace = async (filepath, s3Directory) => {
      return new Promise((resolve, reject) => {
        fs.readFile(filepath, (err, data) => {
          if (err) return reject(err);
          const filename = path.basename(filepath);
          const params = {
            Bucket: process.env.DO_SPACE_NAME,
            Key: [s3Directory, filename].filter(Boolean).join("/"),
            Body: JSON.stringify(data, null, 2),
          AWSS3.upload(params, (s3Err, s3data) => {
            if (s3Err) return reject(s3Err);
            return resolve(s3data.location);
    module.exports = uploadFileToSpace;