Skip to content

How Do I: Cancel and start a new verify2 request #1036

@MaximeCrp

Description

@MaximeCrp

How do I

cancel and start a new verify2 request on SMS channel with same number

API/Product

Verify V2

Code Sample

async restartVerification(
    params: Pick<
      PendingAccount,
      'phoneNumber'
    > & { previousVerificationRequestId: string },
  ) {
    try {
      const e164FormatPhoneNumber = formatPhoneNumberToE164(params.phoneNumber);

      await this.vonage.verify2.cancel(params.previousVerificationRequestId);

      const { requestId: newVerificationRequestId } =
        await this.vonage.verify2.newRequest({
          brand: SMS_BRAND,
          workflow: [{ channel: Channels.SMS, to: e164FormatPhoneNumber }],
          channelTimeout: VERIFICATION_TIMEOUT,
        });
     } catch (error) {...}
}

This code was working fine a few hours ago. Now, it seems some time (a dozen seconds) has to pass between verify2.cancel and verify2.newRequest or Vonage will return a 409 Conflict error, even though request is canceled. We already make sure to only call cancel 30s after request was created

Any idea how to manage that? Is there a limitation on calling new request after calling cancel?

Thank you

Metadata

Metadata

Labels

questionQuestion about how to use the SDKstaleThere has been no activity on this issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions