Skip to main content

Get started (API)

This tutorial will introduce you to the Drive API, DoorDash's API for requesting deliveries fulfilled by our fleet of Dashers. It assumes you're comfortable with the basics of calling web APIs, working with JSON, and writing code in a programming language of your choice.

If you're using Javascript, you should use the Get started (Node.js SDK) tutorial instead.

API: Drive

This doc covers the Drive API. If you're an existing customer using the Drive (classic) API, see the tutorial for getting started with the Drive (classic) APIs.

Table of contents​

  1. Sign into the Developer Portal
  2. Create an access key
  3. Install pre-requisites and create a project
  4. Make a JWT
  5. Create a delivery
  6. Use the Delivery Simulator
  7. Get the status of your delivery
  8. Finish up

Sign into the Developer Portal​

Go to the Developer Portal using the link in the top right corner of this page. If you already have a DoorDash account, enter your email and password and sign in; if not, or if you want to use a different account for development, click Sign Up and follow the process to create an account.

A screenshot of the Developer Portal sign-in screen

Create an access key​

In the left navigation, click Credentials.

A screenshot of the Developer Portal left navigation menu with the Credentials navigation item highlighted

On the Credentials page, click the plus (+) icon in the center of the page to create a new access key. You'll use this access key to create a JSON Web Token (JWT) that you can use to make requests to the Drive API.

A screenshot of the Credentials page with the button for creating a new access key highlighted

Name your key test-app and click Create Access Key.

A screenshot of the modal for creating an access key

Click Copy to copy the access key to your clipboard and then paste it somewhere where you can access it later in the tutorial.

A screenshot of an access key

Install pre-requisites and create a project​

If you don't already have them, install Node.js and npm.

Then, create a directory for your project called test-app and then create a new file named app.js.

Make a JWT​

Install a JWT library​

Most programming languages provide support for creating JSON Web Tokens (JWTs) either directly in the language or as a package. Select your language and then follow the instructions to install the package, if needed.

Open a terminal and navigate to your project directory, then run:

npm install jsonwebtoken

Generate a JWT​

JWTs are created using an access key. Use these code snippets to generate a correctly-formatted JWT from your access key.

Copy the code snippet below into your project file. Replace PASTE_YOUR_ACCESS_KEY_HERE with your access key.

const jwt = require('jsonwebtoken')

const accessKey = PASTE_YOUR_ACCESS_KEY_HERE

const data = {
aud: 'doordash',
iss: accessKey.developer_id,
kid: accessKey.key_id,
exp: Math.floor(Date.now() / 1000 + 60),
iat: Math.floor(Date.now() / 1000),
}

const headers = { algorithm: 'HS256', header: { 'dd-ver': 'DD-JWT-V1' } }

const token = jwt.sign(
data,
Buffer.from(accessKey.signing_secret, 'base64'),
headers,
)

console.log(token)

Then, test your code. In your terminal, run:

node app.js

If you were successful, you should see output like this:

A screenshot of a terminal showing a successful run of the program

Create a delivery​

Now that you have a JWT, you can create a delivery by making a request to the Drive API.

tip

When you created your access key, you created it for the Sandbox environment (until you request production access, you can only create access keys for the Sandbox environment). Because you're using an access key for the Sandbox environment, you can experiment with the API as much as you like without incurring real costs or hailing real Dashers.

First, install the axios npm package.

npm install axios

Then, copy the snippet below into app.js, at the end of the file.

const axios = require('axios')

const body = JSON.stringify({
external_delivery_id: 'D-12345',
pickup_address: '901 Market Street 6th Floor San Francisco, CA 94103',
pickup_business_name: 'Wells Fargo SF Downtown',
pickup_phone_number: '+16505555555',
pickup_instructions: 'Enter gate code 1234 on the callbox.',
dropoff_address: '901 Market Street 6th Floor San Francisco, CA 94103',
dropoff_business_name: 'Wells Fargo SF Downtown',
dropoff_phone_number: '+16505555555',
dropoff_instructions: 'Enter gate code 1234 on the callbox.',
order_value: 1999,
})

axios
.post('https://openapi.doordash.com/drive/v2/deliveries', body, {
headers: {
Authorization: 'Bearer ' + token,
'Content-Type': 'application/json',
},
})
.then(function (response) {
console.log(response.data)
})
.catch(function (error) {
console.log(error)
})

Test your code. In your terminal, run:

node app.js

If you were successful, you should see output like this:

A screenshot of a terminal showing the output of creating a delivery

Use the Delivery Simulator​

You can use the Delivery Simulator to advance your delivery through the stages of the delivery process, from creation to Dasher assignment to pickup to delivery.

In the Developer Portal left navigation, click Simulator.

A screenshot of the Developer Portal left navigation menu with the Simulator navigation item highlighted

Find the delivery you created by looking for the identifier #D-12345. Click Advance to Next Step to move your delivery to the Delivery Confirmed stage.

A screenshot of the Delivery Simulator with a delivery in the Delivery Created stage

Get the status of your delivery​

You can always get the latest status of a delivery by making a request to the Drive API.

First, delete or comment out the request to create a delivery. If you don't, your code will try to create another delivery and run into a conflict.

// axios
// .post('https://openapi.doordash.com/drive/v2/deliveries', body, {
// headers: {
// Authorization: 'Bearer ' + token,
// 'Content-Type': 'application/json',
// },
// })
// .then(function (response) {
// console.log(response.data)
// })
// .catch(function (error) {
// console.log(error)
// })

Copy the snippet below into app.js at the end of the file.

axios
.get('https://openapi.doordash.com/drive/v2/deliveries/D-12345', {
headers: {
Authorization: 'Bearer ' + token,
'Content-Type': 'application/json',
},
})
.then(function (response) {
console.log(response.data)
})
.catch(function (error) {
console.log(error)
})

Then, test your code. In your terminal, run:

node app.js

If you were successful, you should see output like this. Notice that the delivery_status is enroute_to_pickup.

A screenshot of a terminal showing the output of getting delivery status

Finish up​

If you'd like, continue to use the Delivery Simulator to advance your delivery through the stages of the delivery process and then re-run your app to see how the delivery details change.

caution

The code in this tutorial was designed to help you quickly get started with the Drive API. It does not follow security best practices. If you take the code you wrote in this tutorial and bring it into your app:

  1. Don't check the access key into a source control system like Git, and instead use a secret manager or secret store to securely store it
  2. Do remove the line that prints your JWT to the console

Next steps​

Now that you're familiar with the Drive API, you're ready to start adding delivery capabilities to your app! To learn more, use the "How-to guides" section in the navigation on the left side of this page.