Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated May 7, 2024

Set up Amplify REST API

The API category provides a solution for making HTTP requests to REST and GraphQL endpoints. For building GraphQL APIs please visit the GraphQL Getting Started section of our documentation.

The REST API category can be used for creating signed requests against Amazon API Gateway when the API Gateway Authorization is set to AWS_IAM.

Ensure you have installed and configured the Amplify CLI and library.

Automated Setup: Create new REST API

Run the following command in your project's root folder:

amplify add api

Select REST as the service type.

? Please select from one of the below mentioned services

The CLI will prompt several options to create your resources. With the provided options you can create:

  • REST endpoints that triggers Lambda functions
  • REST endpoints which enables CRUD operations on an Amazon DynamoDB table

During setup you can use existing Lambda functions and DynamoDB tables or create new ones by following the CLI prompts. After your resources have been created update your backend with the push command:

amplify push

A configuration file called aws-exports.js will be copied to your configured source directory, for example ./src.

Configure your application

Import and load the configuration file in your app. It's recommended you add the Amplify configuration step to your app's root entry point. For example index.js in React or main.ts in Angular.

import { Amplify, API } from 'aws-amplify';
import awsconfig from './aws-exports';

Manual Setup: Reference existing REST API

For manual configuration you need to provide your AWS Resource configuration and optionally configure authentication.

import { Amplify, API } from 'aws-amplify';
// OPTIONAL - if your API requires authentication
Auth: {
identityPoolId: 'XX-XXXX-X:XXXXXXXX-XXXX-1234-abcd-1234567890ab', // REQUIRED - Amazon Cognito Identity Pool ID
region: 'XX-XXXX-X', // REQUIRED - Amazon Cognito Region
userPoolId: 'XX-XXXX-X_abcd1234', // OPTIONAL - Amazon Cognito User Pool ID
userPoolWebClientId: 'a1b2c3d4e5f6g7h8i9j0k1l2m3' // OPTIONAL - Amazon Cognito Web Client ID (26-char alphanumeric string)
API: {
endpoints: [
name: 'MyAPIGatewayAPI',
endpoint: ''
name: 'MyCustomCloudFrontApi',
endpoint: ''

AWS Regional Endpoints

You can utilize regional endpoints by passing in the service and region information to the configuration. See AWS Regions and Endpoints. The example below defines a Lambda invocation in the us-east-1 region:

API: {
endpoints: [
name: 'MyCustomLambda',
service: 'lambda',
region: 'us-east-1'

The above example IS NOT A RECOMMENDED ARCHITECTURE and we highly recommend you leverage AWS AppSync or API Gateway as the endpoint to invoke your Lambda functions.

Configuring Amazon Cognito Regional Endpoints: To call regional service endpoints, your Amazon Cognito role needs to be configured with appropriate access for the related service. See AWS Cognito Documentation for more details.