メニュー

Expand
ページを評価:

REST API: API キー

You access the Twilio API using API Keys that represent the required credentials. These keys allow you to:

  • Authenticate with Twilio's API
  • Create and revoke Access Tokens

See this document for more information about your request to Twilio's REST API, or read our article on Access Tokens to learn more.

API Keys can be provisioned and revoked through the REST API or the Twilio Console. This provides a powerful and flexible primitive for managing access to the Twilio API. There are two types of API Keys: Standard and Main.

Standard API Keys give you access to all of the functionality in Twilio's API, except for managing API Keys, Account Configuration, and Subaccounts.

Main API Keys have the same access as Standard Keys, and can also manage API Keys, Account Configuration, and Subaccounts. Main API Keys give you the same level of access as if you were using account API Credentials.

APIキーは個別に破棄できます、APIクレデンシャルのライフサイクルを完全に管理できます。

For example, you might issue separate API Keys to different developers or to different subsystems within your application. If a key is compromised or no longer used, you can easily delete it to prevent unauthorized access!

If your use case requires API Keys to access the /Accounts or /Keys endpoint, a Main Key needs to be used. This can be created in the Console.

Key properties

Resource Properties in REST API format
sid
sid<SK> Not PII

The unique string that that we created to identify the Key resource.

friendly_name
文字列 PII MTL: 30 DAYS

The string that you assigned to describe the resource.

date_created
date_time<rfc2822> Not PII

The date and time in GMT that the resource was created specified in RFC 2822 format.

date_updated
date_time<rfc2822> Not PII

The date and time in GMT that the resource was last updated specified in RFC 2822 format.

Create a new API Key

If a new API Key was created successfully, Twilio will respond with a representation of the new API Key.

This representation will be the same as that returned when fetching an API Key's instance resource, but will also include the Secret field.

POST

https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Keys.json

For security reasons the Secret field is ONLY returned when the API Key is first created – never when fetching the resource. Your application should store the API Key's Sid and Secret in a secure location to authenticate to the API and generate Access Tokens in the future.

パラメーター

Parameters in REST API format
account_sid
Path
post sid<AC> Not PII

The SID of the Account that will be responsible for the new Key resource.

friendly_name
オプション
post 文字列 PII MTL: 30 DAYS

A descriptive string that you create to describe the resource. It can be up to 64 characters long.

        
        
        
        
        Create a default API Key

        Create a new API Key

        Create a default API Key
              
              
              
              
              Create an API Key with the FriendlyName, in this case "User Joey".

              Create a new named API Key

              Create an API Key with the FriendlyName, in this case "User Joey".

              Fetch a Key resource

              GET

              https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Keys/{Sid}.json
              

              Returns a representation of the API Key.

              Parameters in REST API format
              account_sid
              Path
              GET sid<AC> Not PII

              The SID of the Account that created the Key resource to fetch.

              sid
              Path
              GET sid<SK> Not PII

              The Twilio-provided string that uniquely identifies the Key resource to fetch.

                    
                    
                    
                    
                    Note that the API Key's Secret field is redacted in the output of this example. As noted above, Secret fields are only returned when the API Key is first created.

                    Fetch an API Key

                    Note that the API Key's Secret field is redacted in the output of this example. As noted above, Secret fields are only returned when the API Key is first created.
                          
                          
                          
                          
                          An example fetching of an API Key.

                          Fetch an API Key

                          An example fetching of an API Key.

                          Read a Key resource

                          GET

                          https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Keys.json
                          

                          Returns a list of API Keys in this account, sorted by DateUpdated.

                          The list includes all API Keys. It also includes paging information.

                          Parameters in REST API format
                          account_sid
                          Path
                          GET sid<AC> Not PII

                          The SID of the Account that created the Key resources to read.

                                
                                
                                
                                
                                Retrieve all the API Keys in an account

                                Read Keys

                                Retrieve all the API Keys in an account

                                Update a Key resource

                                POST

                                https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Keys/{Sid}.json
                                

                                Attempts to update the fields of an API Key instance.

                                If successful, it returns the updated resource representation. The response will be identical to that of the HTTP GET (fetch).

                                Parameters in REST API format
                                account_sid
                                Path
                                post sid<AC> Not PII

                                The SID of the Account that created the Key resources to update.

                                sid
                                Path
                                post sid<SK> Not PII

                                The Twilio-provided string that uniquely identifies the Key resource to update.

                                friendly_name
                                オプション
                                post 文字列 PII MTL: 30 DAYS

                                A descriptive string that you create to describe the resource. It can be up to 64 characters long.

                                      
                                      
                                      
                                      

                                      Delete a Key resource

                                      削除

                                      https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Keys/{Sid}.json
                                      

                                      Deletes an API Key. This revokes its authorization to authenticate to the REST API and invalidates all Access Tokens generated using its secret.

                                      削除に成功すると、本文(Body)のない HTTP 204 レスポンスを返します。

                                      You may only delete Standard or Main API Keys by authenticating the request with AccountSid and AuthToken, or with AccountSID, Main API Key, and the API key's Secret.

                                      Parameters in REST API format
                                      account_sid
                                      Path
                                      削除する sid<AC> Not PII

                                      The SID of the Account that created the Key resources to delete.

                                      sid
                                      Path
                                      削除する sid<SK> Not PII

                                      The Twilio-provided string that uniquely identifies the Key resource to delete.

                                            
                                            
                                            
                                            

                                            Login with an API Key

                                            Using a helper library for the language of your choice, you can use your API Keys to authenticate and use the Twilio REST API.

                                                  
                                                  
                                                  
                                                  
                                                  ページを評価:

                                                  ヘルプが必要ですか?

                                                  誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。

                                                        
                                                        
                                                        

                                                        フィードバックくださりありがとうございます!

                                                        We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

                                                        Sending your feedback...
                                                        🎉 Thank you for your feedback!
                                                        Something went wrong. Please try again.

                                                        Thanks for your feedback!

                                                        Refer us and get $10 in 3 simple steps!

                                                        ステップ1

                                                        Get link

                                                        Get a free personal referral link here

                                                        ステップ2:

                                                        Give $10

                                                        Your user signs up and upgrade using link

                                                        ステップ3

                                                        Get $10

                                                        1,250 free SMSes
                                                        OR 1,000 free voice mins
                                                        OR 12,000 chats
                                                        OR more