tencent cloud

Feedback

CreateInstances

Last updated: 2024-06-17 14:26:28

    1. API Description

    Domain name for API request: postgres.tencentcloudapi.com.

    This API is used to create one or more PostgreSQL instances. Instances created through this interface do not need to be initialized and can be used directly.

  • After an instance is successfully created, it will automatically start up, and its status changes to "Running".
  • For prepaid instances, the required amount for the instance purchase will be deducted in advance. For post-paid hourly instances, the amount required for the purchase within the first hour will be temporarily frozen. Please ensure that your account balance is sufficient before calling this interface.
  • A maximum of 100 requests can be initiated per second for this API.

    We recommend you to use API Explorer
    Try it
    API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

    2. Input Parameters

    The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

    Parameter Name Required Type Description
    Action Yes String Common Params. The value used for this API: CreateInstances.
    Version Yes String Common Params. The value used for this API: 2017-03-12.
    Region No String Common Params. This parameter is not required for this API.
    Zone Yes String Primary AZ of the instance in the format of ap-guangzhou-3. To support multiple AZs, add information of the primary and standby AZs in the DBNodeSet.N field.
    The information of AZ can be obtained from the Zone field in the return value of the DescribeZones API.
    SpecCode Yes String Purchasable code, which can be obtained from the SpecCode field in the return value of the DescribeClasses API.
    Storage Yes Integer Instance storage capacity in GB
    InstanceCount Yes Integer The number of instances to be purchased at a time. Value range: 1-10. To purchase more than 10 instances each time, you can make multiple calls.
    Period Yes Integer Purchase duration, in months.
  • Prepaid: Supports 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 24, and 36.
  • Pay-as-you-go: Only supports 1.
  • Charset Yes String Instance character set, which currently supports only:
  • UTF8
  • LATIN1
  • AdminName Yes String Username of the instance root account, with the following specifications:
  • The username must consist of 1-16 characters, which can be letters, digits, or underscores.
  • It cannot be postgres.
  • It cannot start with digits or 'pg_'.
  • All rules are case-insensitive.
  • AdminPassword Yes String Password for the instance root account username, with a length of 8-32 characters. It is recommended to use a password of more than 12 characters and it cannot start with "/".
    It must include the following four types of characters:
  • Lowercase letters: [a ~ z]
  • Uppercase letters: [A ~ Z]
  • Digits: 0-9
  • Special symbols: ()`~!@#$%^&*-+=_|{}[]:;'<>,.?/
  • DBMajorVersion No String The major version number of PostgreSQL (this parameter is currently required), and the version information can be obtained from DescribeDBVersions. Currently major versions 10, 11, 12, 13, 14, and 15 are supported. For details, see Kernel Version Overview.
    When this parameter is entered, an instance running the latest kernel version of the latest minor version will be created based on this major version number.
    DBVersion No String PostgreSQL community major version + minor version number.
    It's generally not recommended to pass in this parameter. If needed, only the latest minor version number under the current major version can be passed.
    DBKernelVersion No String PostgreSQL kernel version number.
    It's generally not recommended to pass in this parameter. If needed, only the latest kernel version number under the current major version can be passed.
    InstanceChargeType No String Instance billing type, which currently supports:
  • PREPAID: Prepaid, i.e., monthly subscription
  • POSTPAID_BY_HOUR: Pay-as-you-go, i.e., pay by consumption

  • Default value: PREPAID
    VpcId No String VPC ID, in the format of vpc-xxxxxxxx (this parameter is currently required). A valid VpcId can be obtained by logging into the console; it can also be obtained from the unVpcId field in the return value of calling of the DescribeVpcEx API.
    SubnetId No String VPC subnet ID, in the format of subnet-xxxxxxxx (this parameter is currently required). A valid VPC subnet ID can be obtained by logging into the console; it can also be obtained from the unSubnetId field in the return value of calling of the DescribeSubnets API.
    DBNodeSet.N No Array of DBNode Deployment information of the instance node, which will display the information of each AZ when the instance node is deployed across multiple AZs.
    The information of AZ can be obtained from the Zone field in the return value of the DescribeZones API.
    AutoRenewFlag No Integer Renewal Flag:
  • 0: manual renewal
  • 1: auto-renewal

  • Default value: 0
    AutoVoucher No Integer Whether to automatically use coupons:
  • 0: no
  • 1: yes

  • Default value: 0
    VoucherIds.N No Array of String Voucher ID list. Currently, you can specify only one voucher.
    ProjectId No Integer Project ID
    ActivityId No Integer Campaign ID
    Name No String Instance name, which can contain up to 60 letters, digits, hyphens, and symbols (_-). If this parameter is not specified, "Unnamed" will be displayed by default.
    TagList.N No Array of Tag The information of tags to be bound with the instance, which is left empty by default. This parameter can be obtained from the Tags field in the return value of the DescribeTags API.
    SecurityGroupIds.N No Array of String Security group of the instance, which can be obtained from the sgld field in the return value of the DescribeSecurityGroups API. If this parameter is not specified, the default security group will be bound.
    NeedSupportTDE No Integer Whether data transparent encryption is required:
  • 0: no
  • 1: yes

  • Default value: 0See Overview of Data Transparent Encryption.
    KMSKeyId No String KeyId of custom key, which is required if you select custom key encryption. It is also the unique CMK identifier.
    For more information on creating KeyId, see Enabling TDE.
    KMSRegion No String The region where the KMS service is enabled. When KMSRegion is left empty, the current region will be selected by default. If the current region does not support KMS, you must select another region that does.
    For more information on KMSRegion, see Enabling TDE.
    DBEngine No String Database engine, which supports:
  • postgresql: TencentDB for PostgreSQL
  • mssql_compatible: MSSQL compatible - TencentDB for PostgreSQL

  • Default value: postgresql
    DBEngineConfig No String Configuration information for the database engine, and the configuration format is as follows:
    {"$key1":"$value1", "$key2":"$value2"}
    Supported engines include:
    mssql_compatible engine:
  • migrationMode: Database mode, an optional parameter, and its valid values are: single-db (single database schema) and multi-db (multiple database schema). The default value is single-db.
  • defaultLocale: Sorting area rule, an optional parameter, which cannot be modified after initialization, its default value is en_US, and its valid values include:
    "af_ZA", "sq_AL", "ar_DZ", "ar_BH", "ar_EG", "ar_IQ", "ar_JO", "ar_KW", "ar_LB", "ar_LY", "ar_MA", "ar_OM", "ar_QA", "ar_SA", "ar_SY", "ar_TN", "ar_AE", "ar_YE", "hy_AM", "az_Cyrl_AZ", "az_Latn_AZ", "eu_ES", "be_BY", "bg_BG", "ca_ES", "zh_HK", "zh_MO", "zh_CN", "zh_SG", "zh_TW", "hr_HR", "cs_CZ", "da_DK", "nl_BE", "nl_NL", "en_AU", "en_BZ", "en_CA", "en_IE", "en_JM", "en_NZ", "en_PH", "en_ZA", "en_TT", "en_GB", "en_US", "en_ZW", "et_EE", "fo_FO", "fa_IR", "fi_FI", "fr_BE", "fr_CA", "fr_FR", "fr_LU", "fr_MC", "fr_CH", "mk_MK", "ka_GE", "de_AT", "de_DE", "de_LI", "de_LU", "de_CH", "el_GR", "gu_IN", "he_IL", "hi_IN", "hu_HU", "is_IS", "id_ID", "it_IT", "it_CH", "ja_JP", "kn_IN", "kok_IN", "ko_KR", "ky_KG", "lv_LV", "lt_LT", "ms_BN", "ms_MY", "mr_IN", "mn_MN", "nb_NO", "nn_NO", "pl_PL", "pt_BR", "pt_PT", "pa_IN", "ro_RO", "ru_RU", "sa_IN", "sr_Cyrl_RS", "sr_Latn_RS", "sk_SK", "sl_SI", "es_AR", "es_BO", "es_CL", "es_CO", "es_CR", "es_DO", "es_EC", "es_SV", "es_GT", "es_HN", "es_MX", "es_NI", "es_PA", "es_PY","es_PE", "es_PR", "es_ES", "es_TRADITIONAL", "es_UY", "es_VE", "sw_KE", "sv_FI", "sv_SE", "tt_RU", "te_IN", "th_TH", "tr_TR", "uk_UA", "ur_IN", "ur_PK", "uz_Cyrl_UZ", "uz_Latn_UZ", and "vi_VN".
  • serverCollationName: Sorting rule name, an optional parameter, which cannot be modified after initialization, its default value is sql_latin1_general_cp1_ci_as, and its valid values include: "bbf_unicode_general_ci_as", "bbf_unicode_cp1_ci_as", "bbf_unicode_CP1250_ci_as", "bbf_unicode_CP1251_ci_as", "bbf_unicode_cp1253_ci_as", "bbf_unicode_cp1254_ci_as", "bbf_unicode_cp1255_ci_as", "bbf_unicode_cp1256_ci_as", "bbf_unicode_cp1257_ci_as", "bbf_unicode_cp1258_ci_as", "bbf_unicode_cp874_ci_as", "sql_latin1_general_cp1250_ci_as", "sql_latin1_general_cp1251_ci_as", "sql_latin1_general_cp1_ci_as", "sql_latin1_general_cp1253_ci_as", "sql_latin1_general_cp1254_ci_as", "sql_latin1_general_cp1255_ci_as", "sql_latin1_general_cp1256_ci_as", "sql_latin1_general_cp1257_ci_as", "sql_latin1_general_cp1258_ci_as", "chinese_prc_ci_as", "cyrillic_general_ci_as", "finnish_swedish_ci_as", "french_ci_as", "japanese_ci_as", "korean_wansung_ci_as", "latin1_general_ci_as", "modern_spanish_ci_as", "polish_ci_as", "thai_ci_as", "traditional_spanish_ci_as", "turkish_ci_as", "ukrainian_ci_as", and "vietnamese_ci_as".
  • SyncMode No String Primary-standby sync mode, which supports:
  • Semi-sync: Semi-sync
  • Async: Asynchronous

  • Default value for the primary instance: Semi-sync
    Default value for the read-only instance: Async
    NeedSupportIpv6 No Integer Whether support to IPv6 is required:
  • 0: no
  • 1: yes

  • Default value: 0

    3. Output Parameters

    Parameter Name Type Description
    DealNames Array of String Order number list. Each instance corresponds to an order number.
    BillId String Bill ID of frozen fees
    DBInstanceIdSet Array of String ID set of instances which have been created successfully. The parameter value will be returned only when the pay-as-you-go billing mode is used.
    RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

    4. Example

    Example1 Creating a PostgreSQL 12.4 instance

    This example shows you how to create an instance running the latest kernel of PostgreSQL 12.4.

    Input Example

    POST / HTTP/1.1
    Host: postgres.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreateInstances
    <Common request parameters>
    
    {
        "InstanceCount": "1",
        "AutoRenewFlag": "1",
        "AdminName": "test2313",
        "Zone": "ap-guangzhou-2",
        "AdminPassword": " xxxxxxx",
        "DBVersion": "12.4",
        "DBEngine": "postgresql",
        "Storage": "10",
        "Period": "1",
        "SpecCode": "cdb.pg.z1.2g",
        "InstanceChargeType": "prepaid",
        "AutoVoucher": "0",
        "Charset": "UTF8"
    }
    

    Output Example

    {
        "Response": {
            "RequestId": "6ace8140-6b9e-4e81-a8ad-ef3f92b2aa90",
            "DealNames": [
                "20180119110001"
            ],
            "DBInstanceIdSet": [
                "postgres-xxxxx"
            ],
            "BillId": "123"
        }
    }
    

    Example2 Creating a PostgreSQL instance running a specific kernel version

    This example shows you how to create a PostgreSQL instance running kernel v12.4_r1.0.

    Input Example

    POST / HTTP/1.1
    Host: postgres.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreateInstances
    <Common request parameters>
    
    {
        "InstanceCount": "1",
        "AutoRenewFlag": "1",
        "AdminName": "test2313",
        "Zone": "ap-guangzhou-2",
        "AdminPassword": " xxxxxxx",
        "Charset": "UTF8",
        "Storage": "10",
        "Period": "1",
        "SpecCode": "cdb.pg.z1.2g",
        "DBKernelVersion": "v12.4_r1.0",
        "DBEngine": "postgresql",
        "InstanceChargeType": "prepaid",
        "AutoVoucher": "0"
    }
    

    Output Example

    {
        "Response": {
            "RequestId": "6ace8140-6b9e-4e81-a8ad-ef3f92b2aa90",
            "DealNames": [
                "20180119110001"
            ],
            "DBInstanceIdSet": [
                "postgres-xxxxx"
            ],
            "BillId": "123"
        }
    }
    

    Example3 Creating an instance running the latest kernel of PostgreSQL 12

    This example shows you how to create a multi-AZ deployed instance running the latest kernel of PostgreSQL 12.

    Input Example

    POST / HTTP/1.1
    Host: postgres.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreateInstances
    <Common request parameters>
    
    {
        "InstanceCount": "1",
        "AutoRenewFlag": "1",
        "DBMajorVersion": "12",
        "Zone": "ap-guangzhou-2",
        "AdminPassword": " xxxxxxx",
        "Charset": "UTF8",
        "Storage": "10",
        "Period": "1",
        "SpecCode": "cdb.pg.z1.2g",
        "InstanceChargeType": "prepaid",
        "AutoVoucher": "0",
        "DBNodeSet": [
            {
                "Role": "Standby",
                "Zone": "ap-guangzhou-3"
            },
            {
                "Role": "Primary",
                "Zone": "ap-guangzhou-2"
            }
        ],
        "AdminName": "test2313"
    }
    

    Output Example

    {
        "Response": {
            "RequestId": "6ace8140-6b9e-4e81-a8ad-ef3f92b2aa90",
            "DealNames": [
                "20180119110001"
            ],
            "DBInstanceIdSet": [
                "postgres-xxxxx"
            ],
            "BillId": "123"
        }
    }
    

    5. Developer Resources

    SDK

    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    AuthFailure.UnauthorizedOperation Authentication failed.
    FailedOperation.AllocateQuotasError Failed to request a quota for resource tags.
    FailedOperation.CamAuthFailed CAM authentication failed.
    FailedOperation.CamSigAndAuthError Authentication failed. Please try again later. If the problem persists, please contact customer service.
    FailedOperation.CdbCgwConnectError Failed to get project information. Please try again later. If the problem persists, please contact customer service.
    FailedOperation.CreateBasicNetworkDeniedError Classic network creation is unsupported.
    FailedOperation.CreateOrderFailed Failed to create the renewal order.
    FailedOperation.DatabaseAccessError Failed to access database management service. Please try again later. If the problem persists, please contact customer service.
    FailedOperation.DatabaseAffectedError Data operation failed. Please contact customer service.
    FailedOperation.FailedOperationError Operation failed. Please try again later.
    FailedOperation.FlowCreateError Failed to create a task. Please try again later. If the problem persists, please contact customer service.
    FailedOperation.GetSubnetError Failed to query VPC subnets.
    FailedOperation.GetVpcInfoError Failed to query VPC information. Please try again later. If the problem persists, please contact customer service.
    FailedOperation.InvalidTradeOperate Billing error. Corresponding purchase/renewal/configuration change operations are not allowed for the current instance.
    FailedOperation.PayOrderFailed Failed to make order payment.
    FailedOperation.QueryPriceFailed Failed to query the price.
    FailedOperation.QuerySpecError Failed to query specifications. Please try again later. If the problem persists, please contact customer service.
    FailedOperation.QueryVpcFailed Failed to query VPC.
    FailedOperation.QueryVpcFalied Failed to get VPC details.
    FailedOperation.ServiceAccessError Failed to access internal service. Please try again later. If the problem persists, please contact customer service.
    FailedOperation.StorageMemoryCheckError The memory and storage capacity to which an instance is upgraded should be higher than its original memory and storage capacity.
    FailedOperation.TradeCreateError Failed to request the billing platform to create an order.
    FailedOperation.TradePayOrdersError Failed to request to pay for the order.
    FailedOperation.WhitelistConnectError Failed to query the allowlist. Try again later. If the problem persists, contact customer service.
    InternalError.CgwError CGW error.
    InternalError.CnsError Basic network error.
    InternalError.DBError Backend database execution error.
    InternalError.DfwError DFW error.
    InternalError.FlowError Failed to create the flow.
    InternalError.InternalHttpServerError An exception occurred while executing the request.
    InternalError.SystemError System error. When this error occurs, please contact customer service for assistance.
    InternalError.UnknownError Unknown error. When this error occurs, please contact customer service for assistance.
    InternalError.VpcError VPC error.
    InvalidParameter Parameter error.
    InvalidParameter.ParameterCheckError Failed to check the parameter.
    InvalidParameter.TradeAccessDeniedError Incorrect PID
    InvalidParameter.VpcNotFoundError Failed to query VPC information.
    InvalidParameterValue.AccountExist The current account already exists.
    InvalidParameterValue.BadSpec The instance specification to upgrade to is not purchasable.
    InvalidParameterValue.CharsetNotFoundError Incorrect database character set
    InvalidParameterValue.DataConvertError Failed to convert data format. Please contact customer service.
    InvalidParameterValue.IllegalInstanceChargeType Incorrect billing mode.
    InvalidParameterValue.IllegalProjectId Invalid ProjectId.
    InvalidParameterValue.IllegalRegion Invalid Region parameter.
    InvalidParameterValue.IllegalZone Invalid Zone parameter.
    InvalidParameterValue.InterfaceNameNotFound Incorrect ACTION.
    InvalidParameterValue.InvalidAccountError Invalid account. The account name is case-insensitive, must contain 1-16 characters comprised of letters, digits, underscores, and should neither be "postgres" nor start with a digit or "pg_".
    InvalidParameterValue.InvalidAccountFormat Incorrect account format.
    InvalidParameterValue.InvalidAccountName The current account name cannot be a reserved character.
    InvalidParameterValue.InvalidCharset Incorrect database character set. Currently, only UTF8 and LATIN1 are supported.
    InvalidParameterValue.InvalidInstanceNum The number of purchased instances exceeds the limit.
    InvalidParameterValue.InvalidOrderNum Billing error. Invalid order type ID.
    InvalidParameterValue.InvalidParameterValueError Incorrect parameter value
    InvalidParameterValue.InvalidPasswordFormat Incorrect password format.
    InvalidParameterValue.InvalidPasswordLengthError Invalid password. The password length does not meet the requirements.
    InvalidParameterValue.InvalidPasswordValueError Invalid password. The password must contain uppercase letters, lowercase letters, digits, and symbols (()`~!@#$%^&*-+=_|{}[]:;'<>,.?/), and cannot start with a slash (/).
    InvalidParameterValue.InvalidPid Incorrect PID parameter.
    InvalidParameterValue.InvalidZoneIdError Invalid availability zone.
    InvalidParameterValue.ParameterCharacterError Invalid parameter. The parameter can contain only letters, digits, underscores, and hyphens.
    InvalidParameterValue.ParameterHandleError Failed to process the parameter. Please check if the parameter value is valid.
    InvalidParameterValue.ParameterLengthLimitError The length of parameter exceeds the limit.
    InvalidParameterValue.ParameterOutRangeError Invalid parameter values.
    InvalidParameterValue.RegionNotSupported The current region is not supported.
    InvalidParameterValue.SpecNotRecognizedError Failed to identify the specification ({{1}}).
    InvalidParameterValue.StructParseFailed An error occurred while parsing parameters.
    InvalidPid Incorrect PID parameter.
    OperationDenied.CamDeniedError This operation cannot be performed.
    OperationDenied.InstanceStatusLimitOpError This operation cannot be performed on an instance in this status.
    OperationDenied.UserNotAuthenticatedError You need to verify your identity to make a purchase.
    OperationDenied.VpcDeniedError You do not have the permission to operate the VPC.
    ResourceInsufficient.ResourceNotEnough There are not enough resources to purchase instances of this specification in the current region.
    ResourceUnavailable.InvalidInstanceStatus Incorrect instance status.
    ResourceUnavailable.ResourceNoPermission No permission for the VPC.
    ResourceUnavailable.VpcResourceNotFound Failed to get the information of the VPC where the instance resides.
    UnauthorizedOperation.UserHasNoRealnameAuthentication Unverified user.
    UnknownError Unknown error. When this error occurs, please contact customer service for assistance.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support