• Documentation
  • Pricing
© 2026 Serverless, Inc. All rights reserved.

Framework

  • Overview
  • Documentation
  • Plugins360
  • Pricing

Learn

  • Blog
  • GuidesUpdated
  • Examples240
  • Courses

Resources

  • Support
  • Security
  • Trust Center
  • Status

Community

  • Slack
  • GitHub47k
  • Forum
  • Meetups

Company

  • About
  • Careers
  • Contact
  • Partners

Legal

  • Terms of Service
  • Privacy Policy
  • Trademark
  • DMCA
Serverless Framework Logo

Serverless Framework

Intro
SetupUpgrading To V4ConceptsTutorialAWS CredentialsLicense Keys
DeployingPackagingBuildingTestingServicesFunctions
OverviewHTTP (API Gateway v2)REST (API Gateway v1)ActiveMQApplication Load BalancerAlexa SkillAlexa Smart HomeCloudWatch EventCloudWatch LogCloudFrontCognito User PoolEventBridge EventIoTIoT Fleet ProvisioningKafkaKinesis & DynamoDBMSKRabbitMQS3ScheduleSNSSQSWebsocket
LayersManaged InstancesAlertsVersion PruningDomainsIAM Function PermissionsParameters
OverviewSelf-reference serverless.ymlServerless CoreEnvironment VariablesCLI OptionsExternal YAML/JSON FilesJavascript propertiesGitDoppler
OverviewS3 ObjectsSSM Parameter Store & Secrets ManagerCloudFormation Stack Outputs
OverviewVaultTerraform State Output
ResourcesComposing ServicesDeployment BucketStatePython support
OverviewRuntimeGatewayMemoryBrowserCode InterpreterDev Mode
API Gateway Proxy
OverviewGeneral ConfigurationAuthenticationAPI KeysData SourcesResolversPipeline FunctionsCachingDelta SyncCustom DomainWAFCLI Commands
Deploying SAM/CFN TemplatesWorkflow Tips
OverviewCreating PluginsCLI OutputCustom CommandsCustom VariablesExtending the Configuration schemaExtending and overriding configuration
OverviewDashboardAxiom
Overviewpackagedevdeploydeploy functiondeploy listinvokeinvoke locallogsloginlogin awslogin aws ssometricsinforollbackrollback functionremoveplugin installplugin uninstallprintprunesupportusagereconcile
Overview
OverviewMetricsTracesTroubleshoot
OverviewNode.jsPython
OutputsProviders
OverviewBranch DeploymentsPreview DeploymentsCustom ScriptsTestingPrivate PackagesNotificationsMono ReposDeploy in your own CI/CDBest PracticesTroubleshootingFAQ
OverviewSetupToolsAWS Integration
Serverless.yml Reference
Examples and TutorialsConfiguration Validation
  1. Usage
  2. App Sync
  3. API Keys

API Keys

When you use API_KEY as an authentication method, you can control how API keys are created under appSync.apiKeys. It takes an array of API key definitions or strings.

Quick start

appSync:
  apiKeys:
    - john
    - name: jane
      description: Jane's API key.
      expiresAfter: 1M

Configuration

It can either be string, which translates into the API key's name with default values for the other attributes, or use a custom configuration.

  • name: A unique name for this API key. Required.
  • description: An optional description for this API key.
  • expiresAfter: A time after which this API key will expire. See below for more details about expiry. Defaults to 365d.
  • expiresAt: A date-time at which this API key will expire. See below for more details about expiry.
  • wafRules: an array of WAF rules that will apply to this API key only.

Expiry

You can control expiry of the API keys with the expiresAfter or expiresAt attribute.

expiresAfter behaves as a sliding-window expiry date which extends after each deployment. It can be a number of hours until expiry or a more human-friendly string. e.g. 24h, 30d, 3M, 1y.

expiresAt is an exact ISO datetime at which this API will expire. It will not be renewed unless you change this value. e.g. 2022-02-13T10:00:00.

expiresAfter takes precedence over expiresAt. If neither are passed, it defaults to a expiresAfter of 365d

Note: The minimum lifetime of an API key in AppSync is 1 day and maximum is 1 year (365 days). Expiry datetimes are always rounded down to the nearest hour. (e.g. 2022-02-13T10:45:00 becomes 2022-02-13T10:00:00).

Edit this page
Prev AuthenticationNextData Sources

Contents

  • API Keys
  • Quick start
  • Configuration
  • Expiry

Related

GuidesPluginsExamplesSlack CommunitySupport