0.setup--->InstalledPackages--->new
- api request code
String clientId = 'clientId';
String clientSecret = 'clientSecret';
String tokenUrl = 'https://[get this from step 0].auth.marketingcloudapis.com/v2/token';
HttpRequest req = new HttpRequest();
req.setEndpoint(tokenUrl);
req.setMethod('POST');
req.setHeader('Content-Type', 'application/json');
String body = '{"grant_type":"client_credentials","client_id":"' + clientId + '","client_secret":"' + clientSecret + '"}';
req.setBody(body);
Http http = new Http();
HttpResponse res = http.send(req);
Map<String, Object> responseMap = (Map<String, Object>) JSON.deserializeUntyped(res.getBody());
Object accessToken =responseMap.get('access_token');
system.debug(accessToken);
// リクエストJSON
String smsReqJson = '{"ContactKey": "[step 3]",'
+ '"EventDefinitionKey":"get it from journey builder",'
+ '"Data": {'
+ ' "contactkey":"required",'
+ ' "sentdate":"' + String.ValueofGmt(Datetime.now()) + '",'
+ ' "country":"JP",'
+ ' "phone":"yourphone",'
+ ' "name":"yourname"'
+ '}}';
// エンドポイント
String endpoint2 = 'https://[get this from step 0].rest.marketingcloudapis.com/interaction/v1/events';
// HTTPリクエスト
HttpRequest req2 = new HttpRequest();
req2.setEndpoint(endpoint2);
req2.setMethod('POST');
req2.setHeader('Content-Type', 'application/json');
req2.setHeader('Authorization', 'Bearer ' + String.valueof(accessToken));
req2.setBody(smsReqJson);
Http http2 = new Http();
HttpResponse res2 = http2.send(req2);
System.debug(res.getBody());
2.journey builder
api event---> SMS
3.mobile connect
add contacts--->manually or input file
ensure your phone number is correct and your contact key is equal to your api request code